Time Limit: 2000/1000 MS (java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 161285 Accepted Submission(s): 65147
輸入三個字符后,按各字符的ASCII碼從小到大的順序輸出這三個字符。
Input
輸入數據有多組,每組占一行,有三個字符組成,之間無空格。
Output
對于每組輸入數據,輸出一行,字符中間用一個空格分開。
Sample Input
qwe asd zxc
Sample Output
e q w a d s c x z
注意: 每次循環結束后,都要加一個getchar(); 作用是把回車吸收進去
#include<stdio.h>int main(){ char a,b,c,temp; while(scanf("%c%c%c",&a,&b,&c)!=EOF) { if(a<=b) { temp=a; a=b; b=temp; } if(a<=c) { temp=a; a=c; c=temp; } if(b<=c) { temp=b;b=c;c=temp; } printf("%c %c %c/n",c,b,a); getchar(); //必須加 } return 0;}新聞熱點
疑難解答