题目链接:Let the Balloon Rise
解题思路:直接用STL就可以做出来,用map的映射,形成一对一的关系。
#include<stdio.h>
#include<string.h>
#include<string>
#include<map>
using namespace std;
int main(){
string asd;
char color[20];
int i, n, max, index;
while(scanf("%d", &n) && n){
max = -1;
map<string, int> ball;
getchar();
for(i = 0; i < n; i++){
scanf("%s", &color);
asd = string(color);
ball[asd]++;
}
for(map<string, int>::iterator it = ball.begin(); it != ball.end(); it++){
if(it->second > max){
max = it->second;
asd = it->first;
}
}
printf("%s\n", asd.c_str());
}
return 0;
}