Let the Balloon Rise(Map容器)
来源:互联网 发布:刑天seo怎么样 编辑:程序博客网 时间:2024/05/24 04:43
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 87369 Accepted Submission(s): 33024
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.
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.
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
5greenredblueredred3pinkorangepink0
Sample Output
redpink
Author
WU, Jiazhi
#include<cstdio>#include<iostream>#include<map>//引入map容器using namespace std;int main(){ int n,num; string s,ans; while(cin>>n&&n) { num=-5;//存数字 map<string ,int >word;//声明一个关键字为字符串值为数字的map map<string ,int>::iterator it; while(n--) { cin>>s; word[s]++;//关键字的值加一 } for(it=word.begin();it!=word.end();it++) { if(it->second>num) { num=it->second; ans=it->first; } } cout<<ans<<endl; }}
0 0
- Let the Balloon Rise(Map容器)
- Let the Balloon Rise (map)
- 2104:Let the Balloon Rise——map容器
- map容器的应用:hdu 1004 Let the Balloon Rise
- HDUOJ 1004 Let the Balloon Rise(map容器)
- ZOJ 2104/HDU 1004 Let the Balloon Rise(map容器)
- HDU 1004 Let the Balloon Rise(Map)
- HDU-#1004 Let the Balloon Rise(字符串+map)
- Let the Balloon Rise(STL的map)
- HDU 1004 Let the Balloon Rise(STL之map)
- HDU 1004 Let the Balloon Rise (map使用)
- 【hdu 1004】Let the Balloon Rise(map)
- HDU 1004 Let the Balloon Rise (map使用)
- HDU 1004 Let the Balloon Rise(map)
- hdu1004 Let the Balloon Rise && hdu1263 水果(map)
- Hdu oj 1004 Let the Balloon Rise(map)
- HDU 1004(map) Let the Balloon Rise
- Let the Balloon Rise(map+前向迭代器)
- 1032. Sharing (25) -set运用
- easyui动态表头 && 动态添加tabs
- Javascript的DOM操作_测试效果
- qrc文件的使用方法
- Linux iptables之TCP filter分析--tcp-flags --fragment简单分析
- Let the Balloon Rise(Map容器)
- [045] 微信公众平台开发教程第21篇-“可信网址”白名单
- Android SDK Manager需要下载类目
- 北京周边ui设计培训机构哪里好
- 黑马程序员__java基础__反射
- 第十四周(-用文件保存的学生名单)
- HTTP cookie基本理解
- Session的生命周期
- 适合移动手机使用的js环形菜单特效插件