#字符串排序#__huawei_no.14-2

字符串排序

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

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

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

}
// 64 位输出请用 printf("%lld")

显然用sort才是更好的。

全部评论

相关推荐

04-17 10:16
门头沟学院 Java
小浪_coder:24届很难找了,马上25的都毕业了还有很多没找到的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务