码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 1004 Let the Balloon Rise(STL)

时间:2015-08-12 14:46:54      阅读:135      评论:0      收藏:0      [点我收藏+]

标签:stl

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)

标签:stl

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!