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