Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the judges' favorite time is guessing the most popular problem. When the contest is over, they will count the balloons of each color and find the result.

This year, they decide to leave this lovely job to you.

InputInput contains multiple test cases. Each test case starts
with a number N (0 < N <= 1000) -- the total number of balloons
distributed. The next N lines contain one color each. The color of a
balloon is a string of up to 15 lower-case letters.

A test case with N = 0 terminates the input and this test case is not to be processed.

OutputFor each case, print the color of balloon for the most
popular problem on a single line. It is guaranteed that there is a
unique solution for each test case.

Sample Input

  1. 5
  2. green
  3. red
  4. blue
  5. red
  6. red
  7. 3
  8. pink
  9. orange
  10. pink
  11. 0

Sample Output

  1. red
  2. pink
  3.  
  4. 代码:
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <queue>
  4. #include <map>
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int n;
  10. string a,max="a";
  11. map<string,int> b;
  12. while(scanf("%d",&n)&&n)
  13. {
  14. b[max]=;
  15. for(int i=;i<=n;i++)
  16. {
  17. cin>>a;
  18. b[a]++;
  19. if(b[a]>b[max])max=a;
  20. }
  21. cout<<max<<endl;
  22. }
  23. }

Let the Balloon Rise map一个数组的更多相关文章

  1. HDU 1004 Let the Balloon Rise map

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  2. Let the Balloon Rise(map)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  3. Let the Balloon Rise <map>的应用

    Contest time again! How excited it is to see balloons floating around. But to tell you a secret, the ...

  4. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  5. hdoj-1004-Let the Balloon Rise(map排序)

    map按照value排序 #include <iostream> #include <algorithm> #include <cstring> #include ...

  6. HDU 1004 Let the Balloon Rise【STL<map>】

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  7. HDU1004 Let the Balloon Rise(map的简单用法)

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...

  8. hdu 1004 Let the Balloon Rise strcmp、map、trie树

    Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  9. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

随机推荐

  1. [Android教程] Cordova开发App入门(一)创建android项目

    前言 Apache Cordova是一个开源的移动开发框架.允许使用标准的web技术-HTML5,CSS3和JavaScript做跨平台开发. 应用在每个平台的具体执行被封装了起来,并依靠符合标准的A ...

  2. LeetCode--111--最长公共前缀

    问题描述: 给定一个二叉树,找出其最小深度. 最小深度是从根节点到最近叶子节点的最短路径上的节点数量. 说明: 叶子节点是指没有子节点的节点. 示例: 给定二叉树 [3,9,20,null,null, ...

  3. RabbitMq windows 安装

    参考官方网址: http://www.rabbitmq.com/install-windows-manual.html http://www.rabbitmq.com/install-windows. ...

  4. Dubbo项目一段时间后提供者消失

    Dubbo项目用了一段时间后发现接口不通了,错误500 打开监控中心发现提供者不见了 查看下日志文件发现报如下错 2018-08-06 15:10:18,008 [localhost-startSto ...

  5. hdu1686字符串kmp

    The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e ...

  6. jquery添加类

    一.addClass() 方法向被选元素添加一个或多个类. 1.对P元素添加一个intro类.<!DOCTYPE html><html><head lang=" ...

  7. 在命令行中直接运行带main方法的java

    用了很久的java,基本都是交给服务器完成的执行,有page之类的入口,或者是在IDE工具中直接 Run As Java Application. 并且一直对安装java之后配置JAVA_HOME,p ...

  8. Oracle OAF 应用构建基础之实现控制器 (转)

    原文地址: Oracle OAF 应用构建基础之实现控制器 设计一个OA Controller 如OA Framework Page解析中所描述的,OA Controller定义了web beans的 ...

  9. Error: [ng:areq] Argument 'LoginCtrl' is not a function, got undefined

  10. Visual C++ 使用纪要

    1.取消在查找中标记的蓝色小方块 Ctrl+Shift+F2 取消所有标记 2.出现LINK错误 : fatal error LNK1168: cannot open Debug/x.exe for ...