浙大ACM 2104

类别:编程语言 点击:0 评论:0 推荐:

/*
 *    风之彩
 *    email: [email protected]
 */

#include <iostream>
#include <map>
#include <string>
using namespace std;
int main()
{
map<string , int>counts;
string str;
int Num;
while(cin>>Num && Num!=0)
{
     counts.clear();
    for(int i=0;i<Num;i++)
  {
     cin>>str;
     ++counts[str];
  }
  int max;
  map<string,int>::const_iterator iter=counts.begin();
  max=iter->second;
  for(;iter!=counts.end();iter++)
     if(max < iter->second){max=iter->second;str=iter->first;}

   cout<<str<<endl;
}
return 0;
}

本文地址:http://com.8s8s.com/it/it24083.htm