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;
}
快别扯淡了,我什么都不想听