?? hdu1004.cpp
字號:
//*************************************************************************
//*程 序 名:HDu1004.CPP *
//*作 者:FLYLIKEABIRD(LIANG YI MING) *
//*編制時(shí)間:2008.09.08 *
//*主要功能: Let the Balloon Rise *
//*************************************************************************
#include <iostream>
#include <map>
#include <string>
using namespace std;
int main(int argc, char *argv[])
{
int nCount=0;
string strTmp;
while(cin>>nCount&&nCount!=0)
{
map<string,int> mapColor;//用map容器非常方便
for(int i=0;i<nCount;++i)
{
cin>>strTmp;
mapColor[strTmp]++;
}
map<string, int>::iterator iter;
int max = -1;
for(iter = mapColor.begin(); iter != mapColor.end(); iter++)
{//第一次遍歷標(biāo)記最大次數(shù)所在位置
if(iter->second>max)
{
max = iter->second;
}
}
for(iter = mapColor.begin(); iter != mapColor.end(); iter++)
{//第二次遍歷找到標(biāo)記的位置
if(iter->second==max)
{
cout<<iter->first<<endl;
}
}
}
return 0;
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -