⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hdu1004.cpp

📁 杭电ACM1001~1005解体报告
💻 CPP
字号:
//*************************************************************************
//*程 序 名:HDu1004.CPP                                                  *
//*作    者:FLYLIKEABIRD(LIANG YI MING)                                 *
//*编制时间: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++)
       {//第一次遍历标记最大次数所在位置
           if(iter->second>max)
           {
               max = iter->second;
           }
       }
       for(iter = mapColor.begin(); iter != mapColor.end(); iter++)
       {//第二次遍历找到标记的位置
           if(iter->second==max)
           {
               cout<<iter->first<<endl;
           }
       }  
    }
    return 0;
} 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -