首页 > 其他 > 详细

hdu 1004 Let the Balloon Rise(STL)

时间:2015-08-12 14:44:31      阅读:120      评论:0      收藏:0      [点我收藏+]

1代码:

#include<set>
#include<string>
#include<cstring>
#include<cstdio>
#include<iostream>
using namespace std;

set<string> st;
multiset<string> mst;

int main()
{
    int n;
    string s;
    while(scanf("%d",&n)&&n)
    {
        st.clear();
        mst.clear();
        for(int i=0; i<n; i++)
        {
            cin>>s;
            st.insert(s);
            mst.insert(s);
        }
        set<string>::iterator it;
        int maxx=-1;
        for(it=st.begin(); it!=st.end(); it++)
        {
            int cnt=mst.count(*it);
            if(cnt>maxx)
            {
                maxx=cnt;
                s=*it;
            }
        }
        cout<<s<<endl;
    }
    return 0;
}


版权声明:本文为博主原创文章,未经博主允许不得转载。

hdu 1004 Let the Balloon Rise(STL)

原文:http://blog.csdn.net/xky1306102chenhong/article/details/47442873

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!