輸入3個整數,從小到大排序後輸出。將下面的程式填寫完整。
阿新 • • 發佈:2018-11-15
撰寫人——軟工二班——陳喜平
題目描述
輸入3個整數,從小到大排序後輸出。將下面的程式填寫完整。
#include <stdio.h> int main() { int a,b,c,t; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { ........................................ ........................................ printf("%d %d %d\n",a,b,c); } return 0; }
輸入
包括多組測試資料,每組輸入3個整數。
輸出
從小到大排序後的3個整數。
樣例輸入
1 2 3
5 4 6
7 8 2
樣例輸出
1 2 3
4 5 6
2 7 8
提示
來源
hnldyhy
#include <stdio.h> int main() { int a,b,c; int t; while(scanf("%d%d%d",&a,&b,&c)!=EOF) { if(a>b) { t=a; a=b; b=t; } if(a>c) { t=a; a=c; c=t; } if(b>c) {t=b; b=c; c=t;} printf("%d %d %d\n",a,b,c); } return 0; }