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
 
使用C++ STL中的map模板
#include<iostream>
#include<cstdio>
#include<map>
#include<string>
#include<cstring>
using namespace std; void solve()
{
int T, max, t;
map<string, int> color_count;
string color;
while(cin>>T && T) {
max = ;
while(T--) {
cin>>color;
++color_count[color];
}
map<string, int>::const_iterator ii, it;
it = color_count.begin();
while(it != color_count.end()) {
if(max < it->second) {
max = it->second;
ii = it;
}
it++;
}
cout<<ii->first<<endl;
color_count.clear();
}
} int main()
{
solve();
return ;
}

hdoj1004--Let the Balloon Rise的更多相关文章

  1. hdu 1004 Let the Balloon Rise

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

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

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

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

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

  5. HD1004Let the Balloon Rise

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

  6. Let the Balloon Rise(map)

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

  7. akoj-1073- Let the Balloon Rise

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

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

  9. Let the Balloon Rise(水)

    题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  10. ACM Let the Balloon Rise

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

随机推荐

  1. EasyNVR对接EasyCloud视频云平台进行云端录像

    EasyCloud视频云平台是一套能够接入各种类型流,进行统一的设备管理.直播.录像.回放的视频平台,同时,EasyCloud视频云平台集成了云端运维功能,在云端就可以直接维护和控制各个现场的软件运行 ...

  2. sqlserver 脚本和批处理指令小结

    一.脚本基础     1.USE语句          设置当前数据库.     2.声明变量          语法:DECLARE @变量名 变量类型          在声明变量后,给变量赋值之 ...

  3. C语言练习题

    C语言练习题 1. 以下选项中,合法的一组C语言数值常量是(     ) A)028  .5e-3  .0xf B)12.  OXa23   4.5e0 C).177   4e1.5  Oabc D) ...

  4. FTP上传和下载文件的应用

    FTP(File Transfer Protocol)协议主要用来在网络上进行文件传输.FTP通讯除了有一个默认的端口21外,还有其他端口,同城两个端口同时进行数据传输.一个是默认的端口(通常为21) ...

  5. docker desktop

    https://github.com/rogaha/docker-desktop http://blog.csdn.net/tinylab/article/details/45443563

  6. 查找杀死指定进程delphi

    //需要引用tlhelp32单元//查找进程function findProcessId(pname:string):Cardinal; var hsnapshot:THandle; lpe:TPro ...

  7. ffmpeg参数使用说明2

    附录一(ffmpeg参数说明): [参数] [说明] [示例] -i "路径" 指定需要转换的文件路径 -i "C:\nba.wmv" -y 覆盖输出文件,即如 ...

  8. SpringBoot + Thymeleaf + Validate验证

    在开发业务时,不可避免的需要处理一些校验, 如果是写 if-else 这种代码去校验, 那会有一大段这样的代码.不过还好有个校验插件: javax.validation.validation-api  ...

  9. 一、2440裸机点亮led

    从代码開始(先写一个像普通单片机一样的代码): /********led.c************************/ #define GPFCON  (*(volatile unsigned ...

  10. app开发学习需要经历哪些流程

    app开发学习需要经历哪些流程?如何零基础入门app开发?以下是知乎热心开发者的经验总结,对学习app开发有很好的参考意义   1.如果没有编程基础的,学习基础知识的过程肯定是必须的.2.有了一些基础 ...