ASCII码排序

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  
 3 int main(){
 4     char a;
 5     char b;
 6     char c;
 7     char temp;
 8      
 9     while((scanf("%c%c%c",&a,&b,&c))!=EOF){
10         getchar();
11         if(a>b){
12             temp=a;
13             a=b;
14             b=temp;
15         }
16          
17         if(a>c){
18             temp=a;
19             a=c;
20             c=temp;
21         }
22          
23         if(b>c){
24             temp=b;
25             b=c;
26             c=temp;
27         }
28          
29         printf("%c %c %c
",a,b,c);
30     }
31     return 0;
32 }
原文地址:https://www.cnblogs.com/zqxLonely/p/4054464.html