hdu--1004--Let the Balloon Rise

#include<iostream>
#include<map>
#include<string>
using namespace std;
int main()
{
    int N;
    while(cin>>N && N!=0)
    {
        string str;
        map<string,int> bal;
        for(int i=0;i<N;++i){
            cin>>str;
            bal[str]++;
        }
        map<string,int>::iterator it=bal.begin();
        map<string,int>::iterator max_val=it;
        for(++it;it!=bal.end();++it){
            if(it->second>max_val->second){
                max_val=it;
            }
        }
        cout<<max_val->first<<endl;
    }
    return 0;
}

 

posted @ 2017-02-09 15:52  朤尧  阅读(259)  评论(0编辑  收藏  举报