HDOJ 1004 Let the Balloon Rise
/*
HDOJ 1004
STL map的使用
*/
#include <iostream>
#include <string>
#include <map>
using namespace std;
map<string,int> ballon;
string color;
int main()
{
int nCase,_max;
while(cin>>nCase && nCase)
{
ballon.clear(); //使用前要清空
for(int i=0;i<nCase;i++)
{
cin>>color;
ballon[color]++; //map的用法
}
_max=-1;
map<string,int>::const_iterator _ite;
for(_ite=ballon.begin(); _ite != ballon.end() ;_ite++)
{
if(_ite->second > _max)
{
_max=_ite->second;
color=_ite->first;
}
}
cout<<color<<endl;
}
return 0;
}