Description
输入3个整数,按从大到小的书序输出。
Input
12 8 23
Output
23 12 8
Sample Input
10 8 9
Sample Output
10 9 8
Problem Source: 指针
#include<iostream>
using namespace std;
int c[4];
int sort(int *p)
{
int *a,*b,temp;
for(a=p;a<p+3;a++)
for(b=a+1;b<p+3;b++)
if(*a<=*b)
{
temp=*a;
*a=*b;
*b=temp;
}
for(a=p;a<p+3;a++) cout<<*a<<" ";
}
int main()
{
for(int i=0;i<3;i++)
{ cin>>c[i];
}
sort(c);
return 0;
}