题解 | #字符统计#

字符统计

https://www.nowcoder.com/practice/c1f9561de1e240099bdb904765da9ad0

##利用map,set树的自动排序,效率略有提高

#include <iostream>
#include <map>
#include <set>
using namespace std;

int main() {
    char a;
    map<char,int > st;
    map<int,set<char> > st2;

    while (cin >> a ) {
        ++st[a];
    }

    for(auto ite = st.begin();ite != st.end();++ite){
        st2[ite->second].insert(ite->first);
    }

    for(auto ite = st2.rbegin();ite != st2.rend();++ite){
        for(auto ite2= ite->second.begin(); ite2 != ite->second.end(); ++ite2){
            cout<<*ite2;
        }
    }
}

全部评论

相关推荐

高斯林的信徒:问你有没有保底,好人啊,就差把这是kpi面告诉你了
点赞 评论 收藏
分享
no_work_no_life:深圳,充电宝,盲猜anker
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务