题解 | #字符串排序#

字符串排序

https://www.nowcoder.com/practice/5af18ba2eb45443aa91a11e848aa6723?tpId=37&tqId=21237&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fpage%3D1%26tpId%3D37%26type%3D37&difficulty=undefined&judgeStatus=undefined&tags=&title=

#include <iostream>
#include <string>
#include<bits/stdc++.h>
using namespace std;

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

全部评论

相关推荐

评论
1
收藏
分享

创作者周榜

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