题解 | #字符串排序#

字符串排序

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


使用 C++ 容器库 multiset, 重复有序的集合,进行存储和排序处理
#include <string>
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

void paixu()
{
    int n;
    cin >> n;
    multiset<string> oset;    // 可重复的有序集合
    string str;
    while (cin >> str) {
        oset.insert(str);
    }

    set<string>::iterator it = oset.begin();
    while (it != oset.end()) {
        cout << *(it++) << endl;
    }
}

int main()
{
    paixu();

    return 0;
}


#社招#
全部评论

相关推荐

水墨不写bug:疑似没有上过大学
点赞 评论 收藏
分享
每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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