题解 | 直接用stl-map的性质

字符串排序

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

#include <map>
#include <string>
#include <iostream>

using namespace std;

int main()
{
    int n1;
    while (cin>>n1)
    {
        map<string,int> m1;
        string tmp;
        while (n1-->0)
        {
            cin>>tmp;
            ++m1[tmp];
        }
        for(auto iter=m1.begin();iter!=m1.end();)
        {
            cout<<iter->first<<endl;
            --(iter->second);
            if(iter->second==0) ++iter;

        }
        
    }
    return 0;
    
}

全部评论

相关推荐

白火同学:大二有这水平很牛了,可以适当对关键信息加粗一点,比如关键技术、性能指标之类的。
点赞 评论 收藏
分享
水墨不写bug:疑似没有上过大学
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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