輸入一個字符串,長度小於等於200,然後將輸出按字符順序升序排序後的字符串。
測試數據有多組,輸入字符串。
對於每組輸入,輸出處理後的結果。
bacd
abcd
#include <iostream>
using namespace std;
int main()
{
string str;
while(cin >> str)
{
for(int i = str.length() - 1; i >= 0; i--)
{
for(int j = 0; j < i; j++)
{
if(str[j] > str[j + 1])
{
char tmp = str[j];
str[j] = str[j + 1];
str[j + 1] = tmp;
}
}
}
cout << str << endl;
}
return 0;
}
/**************************************************************
Problem: 1054
User: 文劍木然
Language: C++
Result: Accepted
Time:10 ms
Memory:1520 kb
****************************************************************/