博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU1004——Let the Balloon Rise
阅读量:5977 次
发布时间:2019-06-20

本文共 1404 字,大约阅读时间需要 4 分钟。

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
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
using namespace std;int main(){ int n; string color,s; map
Balloon; while(scanf("%d",&n)&&(n!=0)) { Balloon.clear(); for(int i=0;i
>color; Balloon[color]++; } int max=-1; map
::iterator p; for(p=Balloon.begin();p!=Balloon.end();p++) { if((*p).second>max) { max=(*p).second; s=(*p).first; } } cout<
<
 

 

转载地址:http://hpsox.baihongyu.com/

你可能感兴趣的文章
Mybatis 3学习笔记(一)
查看>>
MySQL · 引擎特性 · InnoDB COUNT(*) 优化(?)
查看>>
Guice系列之用户指南(十)
查看>>
树与森林的存储、遍历和树与森林的转换
查看>>
mongodb的读写分离
查看>>
Android自定义属性
查看>>
介绍几个好用的android自定义控件
查看>>
阿里云服务器 Windows连接不成功 提示“你的凭证不工作” 解决方法
查看>>
NVIDIA Jetson TK1学习与开发(八):图文详解OpenGL在Jetson TK1上的安装和使用
查看>>
【性能优化】直方图
查看>>
值类型与引用类型(下)
查看>>
Visual C#之核心语言
查看>>
[J2ME]Nokia播放音乐时发生MediaException的解决办法
查看>>
【转】CSS 与 HTML5 响应式图片
查看>>
代码重构(五):继承关系重构规则
查看>>
使用jquery-easyui写的CRUD插件(2)
查看>>
redis.conf 配置档详解
查看>>
Windows App开发之集合控件与数据绑定
查看>>
Android:Plug-in com.android.ide.eclipse.adt was unable to load class android
查看>>
一分钟了解阿里云产品:对象存储OSS概述
查看>>