题解 | #字符串排序#

字符串排序

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

#include <iostream>
using namespace std;
#include<map>
#include<string>
int main() {
    int num;
    cin >> num;
    string word;
    multimap<string,string> m;
    for(int i = 0;i<num;i++){
        cin >> word;
        m.insert(pair<string,string>(word,word));
    }
    for(auto & it : m){
        cout << it.second << endl;
    }
}

用例中有重复的元素,无所谓,multimap会出手

华为机试刷题记录 文章被收录于专栏

记录一下手打代码的解题思路方便复习

全部评论

相关推荐

卡卡罗特w:是这样的,说的太对了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务