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<stdio.h>
#include<iostream>
#include<string> //这里一定要写
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
//string s;
char s[2300][100],str[2000];
int main()
{
int n,m,i,j,max;
map<string,int>hash;
map<string,int>::iterator it,p;
while(scanf("%d",&n)!=EOF && n!=0)
{
hash.clear();
memset(str,0,sizeof(str));
for(i=1;i<=n;i++){
//cin>>s;
scanf("%s",s[i]);
hash[s[i]]++;
}
max=0;
for(it=hash.begin();it!=hash.end();it++ ){
if(it->second>max){
max=it->second;
p=it;
}
}
cout<<p->first<<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. LeetCode701 二叉搜索树中插入结点

    给定二叉搜索树(BST)的根节点和要插入树中的值,将值插入二叉搜索树. 返回插入后二叉搜索树的根节点. 保证原始二叉搜索树中不存在新值. 注意,可能存在多种有效的插入方式,只要树在插入后仍保持为二叉搜 ...

  2. MySQL中的全局锁和表级锁

    全局锁和表锁 数据库锁设计的初衷是解决并发出现的一些问题.当出现并发访问的时候,数据库需要合理的控制资源的访问规则.而锁就是访问规则的重要数据结构. 根据锁的范围,分为全局锁.表级锁和行级锁三类. 全 ...

  3. 你必须要懂的 Github 开源协议

    作为一个开源社区的活跃者,那些开源协议你都懂什么意思吗? 列两个: Apache License 可以: 商用.修改.分发 但是要声明作者来源和你的修改以及协议 MIT  License 只要声明版权 ...

  4. Memcached repcached 高可用

    Memcached + repcached 高可用环境 repcached 就是一个让memcached的机器能够互为主从,前端可以加一台HAProxy,后端两台memcached互为主从后,写入任何 ...

  5. 日常采坑:.NET Core SDK版本问题

    1..NetCore SDK版本问题 .NetCore3.1 webapi 部署linux,遇到一个坑,开启的目录浏览功能失效,几番尝试发现是版本问题.本地sdk版本与linux安装的sdk版本不对应 ...

  6. 万字长文爆肝 DNS 协议!

    试想一个问题,我们人类可以有多少种识别自己的方式?可以通过身份证来识别,可以通过社保卡号来识别,也可以通过驾驶证来识别,尽管我们有多种识别方式,但在特定的环境下,某种识别方法可能比另一种方法更为适合. ...

  7. 在IDEA中通过Module管理多个项目

    你身边有没有这种顽固的Eclipse忠实用户:IDEA不能一个窗口管理多个项目!太不方便了! 对于一个窗口同时管理多个项目的需求,在我们日常开发时候是经常需要的.尤其当我们在分布式环境下,在一个窗口中 ...

  8. 避免用using包装DbContext【翻译】

    EF和EF Core 的DbContext类实现IDisposable接口.因此,很多最佳编程实践中都建议你将它们放在一个using()块中.不幸的是,至少在Web应用程序中,这样做通常不是一个好主意 ...

  9. 1.8V转5V电平转换芯片,1.8V转5V的电源芯片

    1.8V是一个比较低的电压,在电压供电电压中,1.8V电压的过于小了,在一些电子模块或者MCU中,无法达到供电电压,和稳压作用,PW5100就是可以在1.8V转5V的电平转换电路和芯片,最大可提供50 ...

  10. LR_添加系统资源监控失败

    1.服务开启情况:RPC.Rmote Resgistry.Network DDE.Server.Workstation.Network connection以上服务是否已开启 2.是否开了防火墙,如有 ...