首页 > 代码库 > pdu(No.1004)

pdu(No.1004)

注意是>=

//#define LOCAL
#include<cstdio>
#include<iostream>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int T,maxx;
std::map<string,int> word_count;
std::map<string,int>::iterator be,ed,result;
string word;
void solve()
{
    while(scanf("%d\n",&T)&&T!=0)
    {
        for(int i=0;i<T;i++)
        {
            getline(cin,word,\n);
            word_count[word]++;
        }    
        be=word_count.begin();
        ed=word_count.end();
        maxx=0;
        while(be!=ed)
        {
            if(be->second>=maxx)
            {
                result=be;
                maxx=be->second;
            }
            be++;
        }
        cout<<result->first<<endl;    
        word_count.clear();    
    }    
}
int main()
{
#ifdef LOCAL
    freopen("1004.in","r",stdin);
    freopen("1004.out","w",stdout);
#endif    
    solve();
    return 0;
}