题解 | #字符串排序#

字符串排序

https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;



int main() {
    int num;
    cin>>num;
    vector<string> strs;
    //cin.sync();//这句
    string tmp;
    while(num>=0&&getline(cin,tmp)) {
        if(tmp=="") continue;
        strs.push_back(tmp);
        num--;
    }
    sort(strs.begin(),strs.end());
    for(auto i : strs){
        cout<<i<<endl;
    }
}
// 64 位输出请用 printf("%lld")

记录一下

全部评论

相关推荐

喜欢喜欢喜欢:这是我见过最长最臭的简历
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务