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   我做一些关于map的用法总结
map<string,int>::iterator j;
for (j=color.begin();j!=color.end();++j)
这个是遍历map的方法
map的初始化问题我还没找到解决的方法 于是此题讲其值直接改为零 找到方法之后我来更新
 
 //
// main.cpp
// hdu1004
//
// Created by tupeihui on 15/12/6.
// Copyright © 2015年 admin. All rights reserved.
// #include <iostream>
#include <map>
using namespace std;
map<string,int> color;
char s[];
int main() {
int n; while (scanf("%d",&n))
{
if (n==) break;
for (int i=;i<=n;i++)
{
scanf("%s",s);
color[s]+=;
}
map<string,int>::iterator j;
int ans=;
string anss;
for (j=color.begin();j!=color.end();++j)
{
if (j->second > ans)
{
ans=j->second;
anss=j->first;
}
color[j->first]=;
}
cout<<anss<<endl; }
return ;
}

hdu1004的更多相关文章

  1. HDU1004 (数组元素出现最多)

    HDU1004 思路:求数组中出现次数最多的那个元素: 遍历数组元素,找出每个元素出现的次数 Input Input contains multiple test cases. Each test c ...

  2. HDU1004之总是wa的细节问题

    #include <stdio.h> #include <string.h> int main() { ][]; int n, i, k, j, max, max_i; ){ ...

  3. HDU1004 BALLO0N

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

  4. HDU1004 查气球

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

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

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

  6. HDU1004题解分析(字符串处理)

    这道题是从上个星期开始做的,看到题时觉得似曾相似,好像做过,理了一下思路敲完代码又不对,后来发现是数组用错了,之后又重新想了数组和比较用法,昨天改了一个多小时,后来样例输出全部正确,所有情况都考虑到了 ...

  7. [HDU1004] Let the balloon rise - 让气球升起来

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

  8. 字符串处理-Hdu1004

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 题目大意:给你一个数n,要求输入n个字符串,在这n个字符串中,我们需要输出出现次数最多的字符串. ...

  9. HDU-1004.Let the ballon Rise(STL-map)

    2019-02-28-08:56:03 初次做本题是用字符串硬钢,最近校队训练时又遇到才知道用map是真的舒服.需要注意的是map的用法. clear : 清除map中的所有元素,map.clear( ...

随机推荐

  1. Android开发--apk的生成

    0.前言 此方法为eclipse中生成apk的方法!!!! 1.生成ketstore 在命令提示符中找到java的jdk路径,例如: D:\study software\Java\jdk1.8.0_2 ...

  2. PDF 补丁丁 0.5.0.1816 测试版发布:新界面新体验

    新的测试版简化了界面,操作更直观,同时修复了旧版本的一些错误. 欢迎各位下载测试文件试用,并提出宝贵意见.

  3. clearfix清除浮动

    首先在很多很多年以前我们常用的清除浮动是这样的. 1 .clear{clear:both;line-height:0;} 现在可能还可以在很多老的站点上可以看到这样的代码,相当暴力有效的解决浮动的问题 ...

  4. 实验四 简单的PV操作

    实验四 简单的PV操作 专业 网络工程   姓名 方俊晖 学号 201406114309 一.        实验目的 1.掌握临界区的概念及临界区的设计原则: 2.掌握信号量的概念.PV操作的含义以 ...

  5. ROS语音交互——科大讯飞语音合成TTS(二)

    之前我用过科大讯飞的语音包,为了记录一下我重新使用一下 首先注册科大讯飞账号及应用,以后每个下载的在线使用SDK都是以此账户ID登录讯飞语音服务器. 下载科大讯飞在线合成包. $ unzip Linu ...

  6. 深入了解 JavaScript 中的 for 循环

    在ECMAScript5(简称 ES5)中,有三种 for 循环,分别是: 简单for循环 for-in forEach 在2015年6月份发布的ECMAScript6(简称 ES6)中,新增了一种循 ...

  7. JAVA内存管理

    java与c++之间有一堵由内存动态分配和垃圾收集技术所围成的高墙.墙外面的人想进去,墙里面的人想出去. 1.java内存分布 程序计数器 栈(局部变量.操作数.动态链接.方法出口) 每一个方法从调用 ...

  8. iOS面试题2

    1.写出方法获取ios内存使用情况.// 获取当前设备可用内存及所占内存的头文件 #import <sys/sysctl.h> #import <mach/mach.h> // ...

  9. 关于ZendFramework环境的配置

    在运用PHP进行网站建设的时候,使用框架能够很好的提高编程效率,PHP语言的框架很多,现在普遍使用的是由Zend公司开发的ZendFramework框架,本篇文章是关于ZendFramework的运行 ...

  10. python取文件最后几行

    with open("text.txt") as f:     txt=f.readlines() keys=[k for k in range(0,len(txt))] resu ...