题解 | #字符串排序#

字符串排序

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


#社招#
全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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