题解:
用map存球 然后判断球
#include<iostream>
#include<cstring>
#include<map>
using namespace std;
int main()
{
map<string,int>aaa;
while(true)
{
map<string,int>aaa;
int count=0;
cin>>count;
if(count>0&&count<=1000)
{
string colors;
for(int i=0;i<count;i++)
{
cin>>colors;
if(aaa.find(colors)==aaa.end())
{
aaa.insert(map<string,int>::value_type(colors,1));
}
else
{
aaa[colors]=aaa[colors]+1;
}
}
int c=0;
string color;
for(map<string,int>::iterator it=aaa.begin();it!= aaa.end();++it)
{
if(c<it->second)
{
c=it->second;
color=it->first;
}
}
cout<<color<<endl;
}
else if(count==0)
break;
}
return 0;
}