题解 | 字符串排序
字符串排序
https://www.nowcoder.com/practice/d2f088e655d44e4a85c16f7b99126211
#include <iostream>
using namespace std;
// 掌握字符串string的排序方法:sort(s.begin(),s.end())
int main() {
string s;
while (cin >> s) { // 注意 while 处理多个 case
sort(s.begin(), s.end());
cout << s << endl;
}
}
// 64 位输出请用 printf("%lld")
/*
void mySort(string& s) {
int len = s.length();
for (int i = 0; i<len; i++) {
for (int j = len-1; j>i; j--) {
if (s[j]<s[j-1]) {
swap(s[j], s[j-1]);
}
}
}
}
int main() {
string s;
while (cin >> s) { // 注意 while 处理多个 case
mySort(s);
cout << s << endl;
}
}
// 64 位输出请用 printf("%lld")
*/
