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 <iostream>
#include <string>
#include <map>
using namespace std;
int main(){
map<string,int> col;
string tmp,ans;
int n,max;
while(cin>>n,n){
col.clear();
while(n--){
cin>>tmp;
col[tmp]++;
}
max=;
map<string,int>::iterator it;
for(it=col.begin();it!=col.end();it++){
if(it->second>max){
max=it->second;
ans=it->first;
}
}
cout<<ans<<endl;
} return ;
}

HDU 1004 - Let the Balloon Rise(map 用法样例)的更多相关文章

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

  2. HDU 1004 Let the Balloon Rise(map应用)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

  3. HDU 1004 Let the Balloon Rise(map的使用)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...

  4. hdu 1004 Let the Balloon Rise(字典树)

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

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

  6. hdu 1004 Let the Balloon Rise strcmp、map、trie树

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

  7. hdu 1004 Let the Balloon Rise 解题报告

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 用STL 中的 Map 写的 #include <iostream> #includ ...

  8. hdu 1004 Let the Balloon Rise

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

  9. HDU 1004 Let the Balloon Rise(STL初体验之map)

    Problem Description Contest time again! How excited it is to see balloons floating around. But to te ...

随机推荐

  1. Android图片下载到本地,系统图库不显示

    可能大家都知道我们下载图片到Android手机的时候,然后调用系统图库打开图片,提示"找不到指定项". 那是因为我们插入的图片还没有更新的缘故,所以只要将图片插入系统图库,之后发条 ...

  2. jdbc 日期 时间

    //pstmt.setDate(1, new Date(new java.util.Date().getTime())); pstmt.setTime(1, new Time(new java.uti ...

  3. java 成神之路

    一.基础篇 1.1 JVM 1.1.1. Java内存模型,Java内存管理,Java堆和栈,垃圾回收 http://www.jcp.org/en/jsr/detail?id=133 http://i ...

  4. Gengxin讲STL系列——String

    衔接上一篇引导. 作为第一篇博客,就要大气一点. 可我好像并不知道怎么才能让自己的博客大气一点= =: 明天是我生日,自己先买个中文域名庆祝了一下…… 好了,废话说完了,结果博客也没大气到哪去……,正 ...

  5. c语言 列出-终止系统进程

    #include <stdio.h> #include "stdafx.h" #include <Windows.h> #include <strin ...

  6. U盘开发之SCSI命令

    借助硬件USB协议分析仪,可以清楚的看到U盘启动时和上位机之间交互的USB协议流程,从get desciptor get congfiguration set configuration到scsi命令 ...

  7. 关于SubclassWindow()和SubclassDlgItem

    msdn上的解析 CWnd::SubclassWindowBOOL SubclassWindow( HWND hWnd ); Return Value Nonzero if the function ...

  8. LinearLayout的gravity属性以及其子元素的layout_gravity何时有效;RelativeLayout如何调整其子元素位置只能用子元素中的属性来控制,用RelativeLayout中的gravity无法控制!!!

    LinearLayout的gravity属性以及其子元素的layout_gravity何时有效:RelativeLayout如何调整其子元素位置只能用子元素中的属性来控制,用RelativeLayou ...

  9. Linux常用C函数---字符串转换篇

    函数讲解部分参考http://net.pku.edu.cn/~yhf/linux_c/ atof(将字符串转换成浮点型数) 相关函数 atoi,atol,strtod,strtol,strtoul 表 ...

  10. Linux常用C函数---字符测试篇

    函数讲解部分参考http://net.pku.edu.cn/~yhf/linux_c/ isalnum(测试字符是否为英文或数字) 相关函数 isalpha,isdigit,islower,isupp ...