HDOJ 1004
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 45024 Accepted Submission(s): 15983
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
1 #include <stdio.h>
2 #include <string.h>
3 #include <stdlib.h>
4
5 char ballons[1000][15];
6 int sum[1000];
7 int ballons_idx;
8 int n;
9
10 int InBallons(char* tmp)
11 {
12 int i;
13 for (i=0;i<ballons_idx;i++)
14 {
15 if (strcmp(tmp,ballons[i]) == 0)
16 {
17 sum[i]++;
18 return 1;
19 }
20 }
21 return 0;
22 }
23 int FindMax()
24 {
25 int i, max=-1, idx=0;
26 for (i=0;i<ballons_idx;i++)
27 {
28 if (sum[i]>max)
29 {
30 max = sum[i];
31 idx = i;
32 }
33 }
34 return idx;
35 }
36 void main()
37 {
38 int i;
39 char tmp[15];
40 scanf("%d",&n);
41
42 while(n)
43 {
44 ballons_idx = 0;
45 memset(sum,0,sizeof(int)*1000);
46 for (i=0;i<n;i++)
47 {
48 scanf("%s",tmp);
49 if (InBallons(tmp) == 0)
50 {
51 strcpy(ballons[ballons_idx++],tmp);
52 }
53 }
54 printf("%sn",ballons[FindMax()]);
55 scanf("%d",&n);
56 }
57 }
- CRT连接mysql数据库操作
- 基于springMVC拦截器实现操作日志统计
- datepicker小插件(日期时间 & 日期 & 月份)
- 封装好的MAP工具类和HBASE工具类
- JSP+ajax+springMVC+MayBatis处理excel上传导入
- 绚丽的javascript拾色器(不兼容IE8及以下)
- 魔波广告恶意病毒简析
- javascript生成.xls文件(兼容IE&Chrome&Firefox)
- 没用的程序设计题-美甲帮笔试题
- MongoDB Java
- JSON.parse()和JSON.stringify()
- jquery获取主机地址和端口
- 前端验证码绘制(canvas)
- 关于机器学习在网络安全中的五大误解
- JavaScript 教程
- JavaScript 编辑工具
- JavaScript 与HTML
- JavaScript 与Java
- JavaScript 数据结构
- JavaScript 基本数据类型
- JavaScript 特殊数据类型
- JavaScript 运算符
- JavaScript typeof 运算符
- JavaScript 表达式
- JavaScript 类型转换
- JavaScript 基本语法
- JavaScript 注释
- Javascript 基本处理流程
- Javascript 选择结构
- Javascript if 语句
- Javascript if 语句的嵌套
- Javascript switch 语句
- Javascript 循环结构
- Javascript 循环结构实例
- Javascript 跳转语句
- Javascript 控制语句总结
- Javascript 函数介绍
- Javascript 函数的定义
- Javascript 函数调用
- Javascript 几种特殊的函数
- JavaScript 内置函数简介
- Javascript eval() 函数
- Javascript isFinite() 函数
- Javascript isNaN() 函数
- parseInt() 与 parseFloat()
- escape() 与 unescape()
- Javascript 字符串介绍
- Javascript length属性
- javascript 字符串函数
- Javascript 日期对象简介
- Javascript 日期对象用途
- Date 对象属性和方法
- Javascript 数组是什么
- Javascript 创建数组
- Javascript 数组赋值与取值
- Javascript 数组属性和方法
- 隐藏MySQL InnoDB Cluster / ReplicaSet实例
- MySQL8.0.21——错误日志中的组复制系统消息
- 【一】、搭建Hadoop环境----本地、伪分布式
- 在组复制中指定恢复IP地址
- START GROUP_REPLICATION可以将恢复凭据作为参数
- MySQL Shell转储和加载第1部分:演示!
- MySQL Shell转储和加载第2部分:基准测试
- MySQL Shell转储和加载第3部分:加载转储
- Hadoop【单机安装-测试程序WordCount】
- MySQL Shell转储和加载第4部分:转储实例和模式
- 【创建模式】--工厂模式
- 【创建模式】--Singleton
- Mapreduce 历史服务 配置启动查看
- Yarn 的日志聚集功能配置使用
- HDFS 的垃圾回收配置