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 ...
随机推荐
- python虚拟环境--virtualenv
virtualenv 是一个创建隔绝的Python环境的工具.virtualenv创建一个包含所有必要的可执行文件的文件夹,用来使用Python工程所需的包. 安装 pip install virtu ...
- js实现继承的5种方式
js是门灵活的语言,实现一种功能往往有多种做法,ECMAScript没有明确的继承机制,而是通过模仿实现的,根据js语言的本身的特性,js实现继承有以下通用的几种方式1.使用对象冒充实现继承(该种实现 ...
- mysql乱码配置
1.进入mysql show variables like "char%" 2.在/etc/mysql/my.cnf中增加以下内容 [client] default-c ...
- js中的递归总结
主要从"变量+函数"和"函数+变量"两个方面说明解释. function fun() { // 自己调用自己,称为递归调用 fun(); console.log ...
- java8接口定义增强
java1.7之前,接口中只允许有全局常量和抽象方法,而1.8之后允许在接口中扩充default修饰的普通方法和static修饰的静态方法 其目的是在修改接口中方法的时候,子类就不必去一一修改 pac ...
- vim 多行缩进
按v进入可视化模式后, 选中要缩进的多行, 后按shift+.实现多行缩进.
- [BZOJ 2169]连边
Description 有N个点(编号1到N)组成的无向图,已经为你连了M条边.请你再连K条边,使得所有的点的度数都是偶数.求有多少种连的方法.要求你连的K条边中不能有重边,但和已经连好的边可以重.不 ...
- bzoj 5297: [Cqoi2018]社交网络
Description 当今社会,在社交网络上看朋友的消息已经成为许多人生活的一部分.通常,一个用户在社交网络上发布一条消息 (例如微博.状态.Tweet等)后,他的好友们也可以看见这条消息,并可能转 ...
- Codeforces Round #408 (Div. 2)
C. Bank Hacking 题目大意:给出一棵n个节点的树,每个节点有一个权值,删掉一个点的代价为当前这个点的权值,并且会使其相邻点和距离为2且中间隔着未被删除的点的点权值加1,现在选一个点开始删 ...
- bzoj 1880: [Sdoi2009]Elaxia的路线
Description 最近,Elaxia和w的关系特别好,他们很想整天在一起,但是大学的学习太紧张了,他们 必须合理地安排两个人在一起的时间.Elaxia和w每天都要奔波于宿舍和实验室之间,他们 希 ...