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. U盘变小恢复工具——亲测完美可用

    大白菜U盘,装系统后,U盘损坏,格盘后8G只剩345M,用usbboot恢复到了2G容量.离8G还差很远.用U盘变小恢复工具后,完美恢复到原来大小.在此记录一下,以待下次遇到相似情况使用. 原文地址 ...

  2. iOS FMDB

    FMDB FMDB概述 什么是FMDB * FMDB是iOS平台的SQLite数据库框架 * FMDB以OC的方式封装了SQLite的C语言API FMDB的优点 * 使用起来更加面向对象,省去了很多 ...

  3. c# 使用oledb 写入导出excel设置单元格为成数字格式 设置了不起作用

    使用oledb 导出过程中,如果excel安装版本低于2010,无论怎么设置.导出的都是文本格式. 用代码-使用数据-分列,解决

  4. Pet--hdu4707

    Pet Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submiss ...

  5. PHP中的单例模式

    额,只是复习到这里,做点笔记吧. 单例模式.何谓也?我想就是唯一吧.唯一的意思大概希特勒已经说的很清楚了.就是我也说不明白--把代码贴上来了事. <?php // Single instance ...

  6. PHP配置xdebug

    其实已经做PHP超过2年了,但是今天特别有感触,所以把过程写在这里 环境是win7+apache2.2+php5.3,因为某种原因,必须使用这个版本. 然后就死活配置不出来.apache日志如下: [ ...

  7. python操作redis-hash

    #!/usr/bin/python #!coding: utf-8 import redis if __name__=="__main__": try: conn=redis.St ...

  8. MYSQL 数据类型的 3 个注意

    注意 1. bit(Length) 这种数据类型中,最大长度只可以是64.就是说 bit(2)      对 bit(64)      对 bit(65)      错 bit(100)    错 注 ...

  9. Android网络编程之Http通信

    Android中提供的HttpURLConnection和HttpClient接口可以用来开发HTTP程序.以下是本人在学习中的总结与归纳.1. HttpURLConnection接口    首先需要 ...

  10. 开源日志库log4cplus+VS2008使用

    一.简介     log4cplus是C++编写的开源的日志系统,功能非常全面.本文介绍如何在Windows+VS2008中使用该日志库.   二.下载     可从网站[url]http://log ...