您的位置:首页 > 其它

hdu 1004 Let the Balloon Rise(STL)

2015-08-12 13:09 405 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: