hdu 2000 ASCII碼排序
ASCII碼排序
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 326629 Accepted Submission(s): 126899
Problem Description
輸入三個字符后,按各字符的ASCII碼從小到大的順序輸出這三個字符。
Input
輸入數(shù)據(jù)有多組,每組占一行,有三個字符組成,之間無空格。
Output
對于每組輸入數(shù)據(jù),輸出一行,字符中間用一個空格分開。
Sample Input
qwe
asd
zxc
Sample Output
e q w
a d s
c x z

代碼:
#include <stdio.h>
int main()
{
char a,b,c,d,x,y,z;
while(scanf("%c%c%c%c",&a,&b,&c,&d) != EOF)
{
x=a<b?a:b;
x=x<c?x:c;
z=a>b?a:b;
z=z>c?z:c;
y=a+b+c-x-z;
printf("%c %c %c\n",x,y,z);
}
}
評論
圖片
表情
