题目描述:
输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符。
输入描述:
第一行输入一个数N,表示有N组测试数据。后面的N行输入多组数据,每组输入数据都是占一行,有三个字符组成,之间无空格。
输出描述:
对于每组输入数据,输出一行,字符中间用一个空格分开。
样例输入:
复制
2
qwe
asd
样例输出:
e q w
a d s
代码展示:
#include<stdio.h>
int main ()
{
int i, count=1, number;
scanf("%d", &number);
char str[3], max;
scanf("%s", str);
while(count<=number)
{
if(str[0]>str[1])
{
max=str[0];
str[0]=str[1];
str[1]=max;
}
if(str[0]>str[2])
{
max=str[0];
str[0]=str[2];
str[2]=max;
}
if(str[1]>str[2])
{
max=str[1];
str[1]=str[2];
str[2]=max;
}
printf("%c %c %c\n", str[0], str[1], str[2]);
count++;
scanf("%s", str);
}
return 0;
}