题解 | #字符串内排序#

字符串内排序

https://www.nowcoder.com/practice/cc2291ab56ee4e919efef2f4d2473bac


#include <string>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
int main(){
    string str;
    vector<char> ch;
    while(getline(cin,str)){
        for (int i = 0; i < str.size(); ++i) {
            ch.push_back(str[i]);
        }
        sort(ch.begin(),ch.end());
        for (int i = 0; i < str.size(); ++i) {
            cout<<ch[i];
        }
    }
}

全部评论

相关推荐

月入泉:假的,要你简历,然后说你简历的不足,让你报班的
点赞 评论 收藏
分享
02-25 19:38
门头沟学院 Java
点赞 评论 收藏
分享
评论
2
收藏
分享

创作者周榜

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