问题:比赛时间又一次开始,看到气球漂浮是多么令人兴奋啊!但是,要告诉你一个秘密,法官最喜欢的时间是猜测最受欢迎的问题。当测试结束后,他们将计数每一种颜色的气球,再找出结果。今年,他们决定把最“可爱”的问题留给你。
#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string, int> Ballon;
string color, MaxColor;
int n, max;
while(cin>>n&&n){
Ballon.clear();
while(n--){
cin>>color;
Ballon[color]++;
}
map<string, int>::iterator it;
max = 0;
for(it=Ballon.begin(); it!=Ballon.end(); it++){
if(it->second>max){
max = it->second;
MaxColor = it->first;
}
}
cout<<MaxColor<<endl;
}
return 0;
}