题解 | #字符串内排序#
字符串内排序
https://www.nowcoder.com/practice/cc2291ab56ee4e919efef2f4d2473bac
#include<cstdio> #include<string> #include<algorithm> #include<vector> using namespace std; bool comp(char lhs,char rhs){ return lhs < rhs; } int main(){ char arr[201]; scanf("%s",arr); string s = arr; vector<char> vec; int len = s.size(); for(int i = 0 ; i < len;++i){ vec.push_back(s[i]); } sort(vec.begin(),vec.end(),comp); for(int i = 0 ; i < len ;++i){ printf("%c",vec[i]); } }