0
点赞
收藏
分享

微信扫一扫

[牛客]关于输入输出(stringsteam)

草原小黄河 2022-03-18 阅读 40

对输入的字符串进行排序后输出

打开以下链接可以查看正确的代码

#include "bits/stdc++.h"
using namespace std;

int main() {
    vector<string> s;
    string str;
    while(getline(cin, str)) {
        stringstream ss(str);
        while(getline(ss, str, ',')) {
            s.emplace_back(str);
        }
        sort(s.begin(), s.end());
        for(int i=0;i<s.size();i++) {
            cout<<s[i];
            if(i<s.size()-1)
                cout<<",";
        }
        cout<<endl;
        s.clear();
    }
    return 0;
}
举报

相关推荐

0 条评论