字符串内排序

题目描述:

输入一个字符串,长度小于等于200,然后将输出按字符顺序升序排序后的字符串。

输入:

测试数据有多组,输入字符串。

输出:

对于每组输入,输出处理后的结果。

样例输入:
bacd
样例输出:
abcd
 1 #include <cstdio>
 2 #include <algorithm>
 3 #include <cstring>
 4 using namespace std;
 5 int cmp(char x,char y)
 6 {
 7     return x<y;
 8 }
 9 int main()
10 {
11     char str[210];
12     while (scanf("%s",str)!=EOF)
13     {
14         sort(str,str+strlen(str),cmp);
15         printf("%s\n",str);
16     }    
17     return 0;
18 }
原文地址:https://www.cnblogs.com/aboutblank/p/2917826.html