题解
#include<iostream>
#include<map>
using namespace std;
int main(){
int n;
while(~scanf("%d",&n) && n!=0){
map<string,int> mp;
map<string,int>::iterator it;
string ch;
for(int i=0;i<n;i++){ //注意 map容器的用法
cin>>ch;
mp[ch]++;
}
int cnt=0;
string ans;
for(it=mp.begin();it!=mp.end();it++)
if(it->second >cnt){
cnt=it->second;
ans=it->first;
}
cout<<ans<<endl;
}
return 0;
}
map容器的使用,以及巧妙地在输入时就计算出各种颜色的数目