1-5三整数排序

输入三个整数,从小到大排序后输出
样例输入:
20 7 33
样例输出:
7 20 33

 1 #include<stdio.h>
 2 int main()
 3 {
 4 int a,b,c;
 5 scanf("%d%d%d",&a,&b,&c);
 6 if(a>b){a^=b^=a^=b;}//a<=b
 7 if(b>c){b^=c^=b^=c;}
 8 if(a>b){a^=b^=a^=b;}
 9 printf("%d %d %d",a,b,c);
10 return 0;
11 }

猜你喜欢

转载自www.cnblogs.com/xybz/p/9978878.html