对stl的应用
#include <iostream>
#include "stdio.h"#include <map>
using namespace std;
int main()
{
int n;
while(true)
{
scanf("%d",&n);
if(n == 0 ) break;
map<string,int> mySet;
string color;
for(int i = 0; i < n;i++)
{cin >> color;
map<string,int>::iterator it = mySet.find(color);
if(it == mySet.end())
{
mySet.insert(it,pair<string,int>(color,1));
}
else {
it->second++;
}
}
map<string , int>::iterator itt = mySet.begin();
int max = 0;
string maxColor = "";
while(itt != mySet.end())
{
if(itt->second > max)
{
max = itt->second;
maxColor = itt->first;
}
itt++;
}
cout << maxColor << endl;
}
return 0;
}