输入三个整数,按由小到大的顺序输出
输入要求: 三个整数
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
void fun(int* p1, int* p2, int* p3);
int a, b, c;
cin >> a >> b >> c;
fun(&a, &b, &c);
return 0;
}
void fun(int* p1, int* p2, int* p3)
{
int * temp1, * temp2, * temp3;
if ((*p1) > (*p2))
{
temp1 = p1;
p1 = p2;
p2 = temp1;
}
if ((*p1) > (*p3))
{
temp3 = p1;
p1 = p3;
p3 = temp3;
}
if ((*p2) > (*p3))
{
temp2 = p2;
p2 = p3;
p3 = temp2;
}
cout << *p1 << " " << *p2 << " " << *p3 <<" "<< endl;
}