hdu_1004
来源:互联网 发布:unity3d吃金币 编辑:程序博客网 时间:2024/05/22 10:33
//map的用法
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 73431 Accepted Submission(s): 27435
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 <iostream>#include <map>#include <string>using namespace std;map<string,int> balloon;int main(){ int n; string mycolor; while(cin>>n&&n!=0) { balloon.clear(); while(n--) { cin>>mycolor; balloon[mycolor]++; } int max=0; map<string,int>::iterator ite; for(ite=balloon.begin();ite!=balloon.end();ite++) { if(ite->second>max) { max=ite->second; mycolor=ite->first; } } cout<<mycolor<<endl; } return 0;}
0 0
- hdu_1004
- HDU_1004 balloons
- HDU_1004 Let the Balloon Rise
- HDU_1004 Let the Balloon Rise
- HDU_1004 Let the Balloon Rise
- google authenticator (双重身份验证器)的java使用
- String,StringBuffer与StringBuilder的区别??
- linux find
- JS 替换 window.onload 的 document.ready
- 游戏开发 cocos2d-x 编译成android apk 注意的地方
- hdu_1004
- 计算几何
- PHP4和PHP5的构造函数兼容问题
- SQL语句的一些积累
- Android视图绘制流程完全解析,带你一步步深入了解View(二)
- 又来一段笔试简单代码 计算一年中的第几天
- HDU 2111 Saving HDU (贪心)
- 用Ado.Net实体数据模型 向sql数据库添加数据
- C++ 模板偏特化