pdu(No.1004)

时间:2014-05-16 05:20:32   收藏:0   阅读:294

bubuko.com,布布扣

注意是>=

bubuko.com,布布扣
//#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;
}
bubuko.com,布布扣

 

 

pdu(No.1004),布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!