Problem Description
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.

 
Input
Input 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.

 
Output
For 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
5
green
red
blue
red
red
3
pink
orange
pink
0
 
Sample Output
red
pink
 

分析:map第二弹~

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<ctype.h>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<vector>
#include<map>
using namespace std;
int main()
{
int n;
string color,s;
map<string,int>Balloon;
while(scanf("%d",&n)&&(n!=0))
{
Balloon.clear();
for(int i=0;i<n;i++)
{
cin>>color;
Balloon[color]++;
}
int max=-1;
map<string,int>::iterator p;
for(p=Balloon.begin();p!=Balloon.end();p++)
{
if((*p).second>max)
{
max=(*p).second;
s=(*p).first;
}
}
cout<<s<<endl;
}
return 0;
}

 

HDU1004——Let the Balloon Rise的更多相关文章

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

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

  2. [HDU1004] Let the balloon rise - 让气球升起来

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

  3. hdu1004 Let the Balloon Rise

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

  4. hdu 1004 Let the Balloon Rise

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

  5. Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏

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

  6. 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 ...

  7. HD1004Let the Balloon Rise

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

  8. Let the Balloon Rise(map)

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

  9. akoj-1073- Let the Balloon Rise

    Let the Balloon Rise Time Limit:1000MS  Memory Limit:65536K Total Submit:92 Accepted:58 Description ...

随机推荐

  1. 【BZOJ 2839】 2839: 集合计数 (容斥原理)

    2839: 集合计数 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 399  Solved: 217 Description 一个有N个元素的集合有2 ...

  2. 27.prim算法  最优布线问题(wire.cpp)

    [例4-10].最优布线问题(wire.cpp) [问题描述] 学校有n台计算机,为了方便数据传输,现要将它们用数据线连接起来.两台计算机被连接是指它们间有数据线连接.由于计算机所处的位置不同,因此不 ...

  3. redis配置参数简介

    redis配置查看方式: 1.redis的安装目录查看redis.conf 2.登陆redis客户端,使用 config get xx命令. 比如:查看所有的配置: config get * [roo ...

  4. textbox约束输入值问题解答

    网上很多关于文本框只能输入数字的,今天又找了一遍,发现以前的写法居然有点问题! onkeypress="if (event.keyCode<48 || event.keyCode> ...

  5. VS2012项目中使用CocoStudio相关文件的设置

    开发环境说明: win7  vs2012  coco2d-x 3.0 alpha1 cocos2d-x 3.0 alpha 1搭配CocoStudio使用,效果更佳.CocoStudio包含了游戏开发 ...

  6. Digital Current-Mode Control Challenges Analog Counterparts

    http://electronicdesign.com/digital-ics/digital-current-mode-control-challenges-analog-counterparts ...

  7. ubuntu 包管理详解

    http://www.cnblogs.com/forward/archive/2012/01/10/2318483.html

  8. arcengine帮助http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/what_s_new_for_developers_at_10_/0001000002zp000000/

    http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/index.html#/what_s_new_for_develope ...

  9. FIS常用命令

    命令 用途 简写 fis --version 查看版本 fis -v fis install 安装   fis release 发布项目   fis server start 启动一个服务器用于预览项 ...

  10. MFC 获取DC和输出文字、获取指定区域

    缓存DC的作用:解决闪烁问题 CRect  rect; GetClientRect(rect);获取view视图的区域 CClientDC dc(this); 创建了DC可作图 pdc->Dra ...