题解 | #字符串内排序#
字符串内排序
https://www.nowcoder.com/practice/cc2291ab56ee4e919efef2f4d2473bac
#include <iostream> #include <algorithm> using namespace std; bool cmp(char a,char b){ return a < b; } int main() { string str; cin >> str; int len = str.length(); char* s = new char[len]; for(int i = 0;i < len; i++){ s[i] = str[i]; } sort(s, s + len, cmp); puts(s); return 0; }