题解 | #字符串内排序#
字符串内排序
https://www.nowcoder.com/practice/cc2291ab56ee4e919efef2f4d2473bac
#include<bits/stdc++.h> using namespace std; int main() { string str; while (cin >> str) {//输入字符串 if (str.length() == 0) { break; } sort(str.begin(), str.end());//对字符串中的字符进行排序 cout << str << endl;//输出排好序的字符串 } }
string的排序:sort(s.begin(),s.end())