ACM Let the Balloon Rise
This year, they decide to leave this lovely job to you.
InputInput 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.
OutputFor 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 代码逻辑值得玩味
/*
Name: Let the Balloon Rise
Copyright:
Author:
Date: 09/08/17 17:01
Description: 寻找颜色出现次数最多的气球
*/
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
int n;
int num[];
char ch[][];
while(cin>>n && n)
{
memset(num,,sizeof(num));
for(int i = ; i < n; i++)
{
cin>>ch[i];
for(int j = ; j < i; j++)
if(strcmp(ch[j],ch[i]) == ) num[i]++;
}
int max = num[];
int t = ;
for(int i = ; i < n; i++)
{
if(max < num[i])
{
max = num[i];
t = i;
}
}
cout<<ch[t]<<endl;
} return ;
}
ACM Let the Balloon Rise的更多相关文章
- 【ACM】hdu_1004_Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- 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 ...
- Let the Balloon Rise(水)
题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=1004 Let the Balloon Rise Time Limit: 2000/1000 MS (J ...
- 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 ...
- 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 ...
- hdu 1004 Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- Let the Balloon Rise 分类: HDU 2015-06-19 19:11 7人阅读 评论(0) 收藏
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- 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 ...
- HDU1004 Let the Balloon Rise(map的简单用法)
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
随机推荐
- 屏幕上两点画线+DDALine算法
编译环境VS2017+EasyX #include "stdafx.h" #include"graphics.h" void DDALine(int x0, i ...
- 多线程编程、java图形用户界面编程、Java I / O系统
线程概述 进程:是一种 “自包容”的运行程序 线程是进程当中的一个概念,最小处理单位 THread类.Runnable接口.Object类 创建新执行线程有两种方法:1:一种方法是将类声明为Threa ...
- MyBatis基础学习笔记--摘录
1.MyBatis是什么? MyBatis源自于IBatis,是一个持久层框架,封装了jdbc操作数据库的过程,使得开发者只用关心sql语句,无需关心驱动加载.连接,创建statement,手动设置参 ...
- ES6 new syntax of Rest and Spread Operators
Rest and Spread Operators.md Why we need rest and spread operators? var showCollections = function(i ...
- 前端页面间传值之cookie传值和url传值
大家好,我是小C: 我们在做一些网站需要传值交互,最近我就遇到了这问题,如果用H5的本地存储,IE8以下是不能支持的,但是官方说到IE8及以上就支持,但是某些版本还是存在问题.所以我们来看看下面两种方 ...
- Kylin系列之二:原理介绍
Kylin系列之二:原理介绍 2018年4月15日 15:52 因何而生 Kylin和hive的区别 1. hive主要是离线分析平台,适用于已经有成熟的报表体系,每天只要定时运行即可. 2. Kyl ...
- [ZJOI2006]超级麻将
题目描述 很多人都知道玩麻将,当然也有人不知道,呵呵,不要紧,我在这里简要地介绍一下麻将规则: 普通麻将有砣.索.万三种类型的牌,每种牌有1~9个数字,其中相同的牌每个有四张,例如1砣~9砣,1索~9 ...
- Codeforces Round #460 E. Congruence Equation
Description 题面 \(n*a^n≡b (\mod P),1<=n<=x\) Solution 令 \(n=(P-1)*i+j\) \([(P-1)*i+j]*a^{[(P-1) ...
- ●BOZJ 2229 [Zjoi2011]最小割
题链: http://www.lydsy.com/JudgeOnline/problem.php?id=2229 题解: 首先先去看看这个博客:http://blog.csdn.net/jyxjyx2 ...
- hdu 4283 区间dp
You Are the One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...