竞赛讨论区 > c++ stringstream
头像
彼岸蒹葭
发布于 2020-03-22 18:20
+ 关注

c++ stringstream

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <sstream>
#include <algorithm>
#include <cstdlib>
using namespace std;

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



全部评论

(0) 回帖
加载中...
话题 回帖

等你来战

查看全部

热门推荐