小墨在努力!!
吗了个b的。。。。。

map的使用,还不是很会用啊。。。。

#include <iostream>
#include <string>
#include <map>
using namespace std;
int main()
{
int n;
string s,s2;
while(scanf("%d",&n)&&n!=0)
{
map <string,int> m;
map <string,int> :: iterator p;
for (int i = 1;i <= n;i++)
{
cin>>s;
m[s]++;
}
int max=-1;
for (p = m.begin();p!=m.end();p++)
if(p->second > max)
{
max = p->second;
s2 = p->first;
}
cout<<s2<<endl;
}
return 0;
}

 

posted on 2012-02-13 18:52  小墨在努力!!  阅读(142)  评论(0编辑  收藏  举报