#字符串排序#__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才是更好的。

全部评论

相关推荐

05-01 22:41
中南大学 Java
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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