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