hdoj Let the Balloon Rise
/*Let the Balloon Rise
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*/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
# define N 1005
char str[N][15];
int main()
{
int i,j,count[1000],t,n,k;
while(scanf("%d",&n),n!=0)
{
t=0;记着要清零。
for(i=0;i<n;i++)
scanf("%s",str[i]);
memset(count,0,sizeof(int)*1000);//把count都初始为0
for(i=0;i<n;i++)
{
for(j=i+1;j<=n;j++)
{
if(strcmp(str[i],str[j])==0)
{
count[t]++;
}
}
t++;
}
k=0;
for(i=0;i<t;i++)
{
if(count[i]>=count[k])
k=i;
}
printf("%s\n",str[k]);
}
return 0;
}
hdoj Let the Balloon Rise的更多相关文章
- 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 ...
- HD1004Let the Balloon Rise
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others ...
- Let the Balloon Rise(map)
Let the Balloon Rise Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Oth ...
- akoj-1073- Let the Balloon Rise
Let the Balloon Rise Time Limit:1000MS Memory Limit:65536K Total Submit:92 Accepted:58 Description ...
- 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 ...
随机推荐
- input只能输入数字或两位小数
/** * [只能输入数字和两位小数] * 举例:<input type="text" onkeyup="num(this)" size="10 ...
- VUE使用中踩过的坑
前言 vue如今可谓是一匹黑马,github star数已居第一位!前端开发对于vue的使用已经越来越多,它的优点就不做介绍了,本篇是我对vue使用过程中以及对一些社区朋友提问我的问题中做的一些总结, ...
- CRM系统 - 总结 (二) stark组件
介绍: stark组件,是一个帮助开发者快速实现数据库表的增删改查+的组件.目标: 10s 中完成一张表的增删改查. 前戏: django项目启动时,自定义执行某个py文件. django启动时,且在 ...
- js 如何判断浏览器是否禁用cookie
语法:navigator.cookieEnabled: 如果浏览器启用了cookie,该属性值为true.如果禁用了cookie,则值为false. navigator: JavaScript中的一个 ...
- fetch 如何请求数据
fetch 如何请求数据 在 传统Ajax 时代,进行 API 等网络请求都是通过XMLHttpRequest或者封装后的框架进行网络请求,然而配置和调用方式非常混乱,对于刚入门的新手并不友好 二 与 ...
- vargrind 安卓apk
上层为安卓, 下层为调用c/c++ 库 1.将vargind 按官网方法下载源代码编译 得Inst文件夹 2.通过win 下安卓sdk 中 platform-tools 中的adb push Ins ...
- Maven传递依赖的时候,同名包不同版本号的包均会下载,可是编译的时候,仅仅会载入一个高版本号的。
描写叙述,在一个Maven项目中.同一时候依赖了spring-tomcat-weaver 和 struts-core 包.可是spring-tomcat-weaver 须要commons-dige ...
- IE input X 去掉文本框的叉叉和password输入框的眼睛图标
IE input X 去掉文本框的叉叉和password输入框的眼睛图标 从IE 10開始,type="text" 的 input 在用户输入内容后.会自己主动产生一个小叉叉(X) ...
- apiCloud实现加载更多效果,基本完美~
apiCloud实现加载更多效果 1.接口支持,加入参数page. $page = $this->_request('page','trim','1'); $pagesize = 10; // ...
- 27.boost多线程
#define _CRT_SECURE_NO_WARNINGS #include <boost/thread.hpp> #include <iostream> #include ...