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. 了解一下ajax

    AJAX:是一种无需重新加载页面的情况下能够更新部分(局部更新)网页的技术. 1. 概念:ASychronous JavaScript And XML 异步的JavaScript和XML 首先了解一下 ...

  2. python学习笔记 | 顺序表的常规操作

    ''' @author: 人人都爱小雀斑 @time: 2020/3/11 8:46 @desc: 顺序表的相关操作 ''' class SequenceList: def __init__(self ...

  3. docker 删除和拉取镜像

    删除镜像 # docker rmi -f 镜像id # 删除指定镜像 docker rmi -f 25d5f6s564 # docker rmi -f 镜像id 镜像id # 删除多个镜像 docke ...

  4. 【ORA】 ORA-01031:权限不足的问题

    今天创建一个用户,赋予dba权限,在plsql中选择sysdba登录,但是报错 ORA-01031 在网上找了好久最后的解决办法是 不仅仅要有dba权限 还要有这个权限: grant all priv ...

  5. CTFshow萌新赛-千字文

    打开靶机 下载完成后,为一张二维码图片 使用StegSolve 解出隐写图像 保存后使用PS或其他工具去除白边 然后使用脚本分割这个图像(25*25) from PIL import Image im ...

  6. thinkpad8平板安装win10系统

    ThinkPad8 因为是平板电脑,只有一个micro USB接口,常规安装没法使用鼠标或键盘进行输入,所以难倒很多人. 幸好前段时间买了根otg线和3.0usb hub,安装方法记录如下: 准备:U ...

  7. python无法连接mysql,有个小坑,需要注意一下!

    尝试用python链接mysql数据库,按照教程里链接了小半夜,就是没有链接上,找了各种文章,最后发现是版本的问题,我想使用的模块是MySQLdb,刚刚去他们的官网看了一下,最近一次更新是2014年, ...

  8. StringBuilder和输入输出

    构建字符串(StringBuilder的应用) 有些时候,需要由较短的字符串构建字符串,例如:按键或来自文件的单词,采用字符串连接的方式达到此目的效率比较低.每次连接字符串,都会构建一个新的Strin ...

  9. 【工具篇】Mysql的安装和使用

    [导读]Mysql是数据分析师入门级的技能之一,对于很多小白同学来说,可能还没有机会接触SQL知识.那么我们如何熟悉和练习SQL呢,今天教大家安装两个软件:MySQL和Navicat.后续我们会推出S ...

  10. 在.NET Core 中使用Quartz.NET

    Quartz.NET是功能齐全的开源作业调度系统,可用于最小的应用程序到大型企业系统. Quartz.NET具有三个主要概念: job:运行的后台任务 trigger:控制后台任务运行的触发器. sc ...