题解 | 字符串排序

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

int main() {
    int n;
    cin >> n;
    string str;
    vector<string> instr;
    for(int i=0 ; i<n ; i++){
        cin >> str;
        instr.push_back(str);
    }
    sort(instr.begin(),instr.end());
    for(int i=0 ; i<n ; i++){
        cout << instr[i] << endl; 
    }

}

全部评论

相关推荐

12-19 22:04
武汉大学 Java
点赞 评论 收藏
分享
11-27 14:21
同济大学 Java
卢来猴祖:给了这薪资关键拿不了几个月就给你踹了呀
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
11-19 14:56
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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