要求:从小到大输出
分析:
先比较a,b,找出两个中大的一个,进行交换,现在 a是小的,b是大的;
接下来需要找最小的,于是比较a,c,现在a是最小的,c是大的;
最后比较b,c,如果b>c,就进行交换,这时c就是最大的,b是中间的;
输出。
#include <stdio.h>
int main(){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if(a>b){
int t;
t=a;
a=b;
b=t;
}
if(a>c){
int t;
t=a;
a=c;
c=t;
}
if(b>c){
int t;
t=b;
b=c;
c=t;
}
printf("%d %d %d",a,b,c);
return 0;
}