`
googlelc
  • 浏览: 60016 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

hdoj1004

 
阅读更多
 #include<iostream>
using namespace std;
#include<string>
#include<map> 
int main()
{
  int n,i;
  map<string,int> ball;
  while( cin >> n)
  {
        if(n==0)break;
        ball.clear();
        string color,pcolor;
        for( i = 0;i<n;i ++)
        {
             cin >> color;
             if(ball.count(color)==0)
             {
                  ball.insert(pair<string,int>(color,1));                   
                                     }
              else 
              {
                   ball[color]++;
                   }                       
             }
           map<string,int>::iterator it;
           int count = -1;
           for( it=ball.begin();it!=ball.end();it++)
           {
                if((*it).second>count)
                {
                count = (*it).second;
                pcolor = (*it).first;
                                      }
                } 
             cout << pcolor << endl;    
         }
    system("pause");
    } 


分享到:
评论

相关推荐

    hdoj1004 解题代码 答案

    hdoj1004,解题代码,答案代码,欢迎下载

    HDOJ1004

    ACM ICPC HDOJ1004

    hdoj杭电入门训练题

    Let the Balloon Rise (HDOJ1004) **知识点:** - 字符串处理。 - 字符串匹配算法。 **解题思路:** - 读入字符串。 - 使用循环或字符串函数检查字符串是否包含特定字符序列。 - 如果包含,则输出“YES”,否则...

    ACM 程序设计竞赛入门:第2讲 数学问题.ppt

    在ACM竞赛的实践中,我们可以将数学问题分为不同的类别,例如简单的数学问题,像HDOJ1004: Let the Balloon Rise这样的题目,可能涉及基础的算术运算和逻辑推理。通过不断练习和深入学习,参赛者能够提升自己在面对...

    杭电OJ使用说明书 HDOJ使用说明书

    杭电OJ(HDOJ)是杭州电子科技大学开发并维护的在线编程竞赛平台,为学习编程、提升算法能力的用户提供了一个实践和竞技的场所。 **二、注册与登录** 1. 注册:首次使用HDOJ的用户需要进行注册,通过填写用户名、...

Global site tag (gtag.js) - Google Analytics