题解 | 字符串排序

#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; 
    }

}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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