题解 | #字符串排序#

字符串排序

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")

全部评论

相关推荐

牛客92804383...:在他心里你已经是他的员工了
点赞 评论 收藏
分享
uu们,拒offer时hr很生气怎么办我哭死
爱睡觉的冰箱哥:人家回收你的offer,或者oc后没给你发offer的时候可不会愧疚你,所以你拒了也没必要愧疚他。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务