题目链接:http://ac.jobdu.com/problem.php?pid=1054
题目分析:
简单的排序。设置字符串保存输入数据,然后排序。
源代码:
#include <iostream>
#include <string>
using namespace std;
int main()
{
string s;
while (cin>>s)
{
if (s.length() > 200)
{
break;
}
char a;
for (int i = 0; i < s.length(); i++)
{
for (int j = i + 1; j < s.length(); j++)
{
if (s[i] > s[j])
{
a = s[i];
s[i] = s[j];
s[j] = a;
}
}
}
cout<<s<<endl;
}
}
本文介绍了一个简单的排序问题解决方法,通过读取输入的字符串并使用基本的冒泡排序算法进行字符排序,最后输出排序后的字符串。
482

被折叠的 条评论
为什么被折叠?



