题解 | #字符串排序#
字符串排序
https://www.nowcoder.com/practice/d2f088e655d44e4a85c16f7b99126211
#include <bits/stdc++.h>
using namespace std;
bool cmp(char c1,char c2){
return (int)c1<(int)c2;
}
int main() {
vector<char>st;
string s;
while(getline(cin,s)){
if(s.length()==0)return 0;
else{
for(int i =0;i<s.length();i++)
st.push_back(s[i]);
sort(st.begin(),st.end(),cmp);
for(auto a:st)
cout<<a;
}
}
}
// 64 位输出请用 printf("%lld")
查看6道真题和解析
