題目分析:
簡單的排序。設置字符串保存輸入數據,然後排序。
源代碼:
[cpp]
#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;
}
}
#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;
}
}