C++题解 | #字符串排序 10行代码#
字符串排序
http://www.nowcoder.com/practice/5190a1db6f4f4ddb92fd9c365c944584
#include <iostream>
using namespace std;
int main(){
string str;
char out[1000];
int k = 0;
getline(cin, str);
for(int i = 0; i < 26; ++i)
for(int j = 0; j < str.size(); ++j)
if(str[j]-'a'==i || str[j]-'A'==i)
out[k++] = str[j];
k = 0;
for(int i = 0; i < str.size(); ++i)
if(isalpha(str[i]))
str[i] = out[k++];
cout << str;
}