ASCII码排序
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 81279 Accepted Submission(s): 33769
Problem Description
输入三个字符后,按各字符的ASCII码从小到大的顺序输出这三个字符。
Input
输入数据有多组,每组占一行,有三个字符组成,之间无空格。
Output
对于每组输入数据,输出一行,字符中间用一个空格分开。
Sample Input
qwe
asd
zxc
Sample Output
e q w
a d s
c x z
1 #include<stdio.h> 2 int main() 3 { 4 char a, b, c, t; 5 while(scanf("%c%c%c", &a, &b, &c) == 3) 6 { 7 getchar();//吸收回车符 8 if(a > b) 9 { 10 t = a; 11 a = b; 12 b = t; 13 } 14 if(a > c) 15 { 16 t = a; 17 a = c; 18 c = t; 19 } 20 if(b > c) 21 { 22 t = b; 23 b = c; 24 c = t; 25 } 26 printf("%c %c %c ", a, b ,c); 27 } 28 return 0; 29 }