《算法笔记》4.1小节-排序
问题 D: 字符串内排序
题目描述
输入一个字符串,长度小于等于200,然后将输出按字符顺序升序排序后的字符串。
输入
测试数据有多组,输入字符串。
输出
对于每组输入,输出处理后的结果。
样例输入
tianqin
样例输出
aiinnqt
提示
注意输入的字符串中可能有空格。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main()
{
char str[201];
while(gets(str)!=NULL)
{
int len=strlen(str);
sort(str,str+len);
puts(str);
}
return 0;
}