Let the Balloon Rise

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)

Total Submission(s): 93272    Accepted Submission(s): 35595

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>
char str[1001][100],a[100];
int b[1000];
int main()
{
int n;
while(scanf("%d",&n),n)
{
int cnt=0,flog,max=0,op;
for(int i=0;i<n;i++)
{
memset(a,'\0',sizeof(a));
flog=0;
scanf("%s",a);
if(i==0)
{
strcpy(str[cnt++],a);continue;
}
else
{
for(int j=0;j<cnt;j++)
if(strcmp(str[j],a)==0)
{
flog=1;b[j]++;
if(b[j]>max)
{
max=b[j];
op=j;
}
}
if(!flog)
strcpy(str[cnt++],a);
}
}
printf("%s\n",str[op]);
}
return 0;
}

hdoj-1004-Let the Balloon Rise(水题)的更多相关文章

  1. HDOJ 1004 Let the Balloon Rise

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

  2. HDOJ 1004 Let the Balloon Rise (字符串+stl)

    题目: Problem Description Contest time again! How excited it is to see balloons floating around. But t ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 杭电1004 Let the Balloon Rise

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

  7. hdu 1004 Let the Balloon Rise

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

  8. 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 ...

  9. HDOJ/HDU 1328 IBM Minus One(水题一个,试试手)

    Problem Description You may have heard of the book '2001 - A Space Odyssey' by Arthur C. Clarke, or ...

  10. HDOJ(HDU) 2090 算菜价(简单水题、)

    Problem Description 妈妈每天都要出去买菜,但是回来后,兜里的钱也懒得数一数,到底花了多少钱真是一笔糊涂帐.现在好了,作为好儿子(女儿)的你可以给她用程序算一下了,呵呵. Input ...

随机推荐

  1. dhtmlxtree动态加载节点数据的小随笔

    最近做了一个这个东西,颇有些感触,随笔记录一下自己的过程. 首先特别感谢:https://blog.csdn.net/cfl20121314/article/details/46852591,对我的帮 ...

  2. SLAM: Ubuntu14.04_Kylin安装ROS-Indigo

    参考连接:ROS-Indigo版在Ubuntu上的安装第一步: 软件源配置 1. 增加下载源(增加ubuntu版的ros数据仓库,即下载源)(通用指令适合任何版本的ros) sudo sh -c 'e ...

  3. SLAM: VSLAM扫盲之旅

    在<机器人手册> 第2卷,这本书里面,第23章讲述了:三维视觉和基于视觉的实时定位于地图重建.在第37章里面,讲述了 同时定位与建图.指出了SLAM的三种基本方法. 一种是EKF的方法,但 ...

  4. 极客学院免费VIP

    [手快福利]用我的链接注册极客学院,你我都能免费得30天VIP!6500+编程开发视频教程随便学,还能下载资料和源码 http://e.jikexueyuan.com/invite/index.htm ...

  5. MVC 运行视图出错

    IIS服务器web核心没有安装造成的

  6. nginx_安装测试

    首先安装环境: [root@local nginx-1.9.14]#  yum install gcc-c++  pcre pcre-devel  zlib zlib-devel openssl op ...

  7. 数据库Day3之SQL Server 触发器

    最近在做一个人事管理系统写了几个简单的触发器 1.在删除员工信息表中员工信息时结果区提示被删除员工信息 create trigger teston 员工信息表after deleteasselect ...

  8. Day5 练习

    1. 2. 要加强对代码效率的思考 3. 4. 知识点:1)多变量的同时赋值 2)元素的不可修改性:(1,2)=(3,4)与(a,b)= (b,a)     联想指针.地址去理解  :可用id()或t ...

  9. 【剑指Offer】58、对称的二叉树

      题目描述:   请实现一个函数,用来判断一颗二叉树是不是对称的.注意,如果一个二叉树同此二叉树的镜像是同样的,定义其为对称的.   解题思路:   本题判断一棵树是不是对称的,和第18题可以对比分 ...

  10. 【剑指Offer】16、合并两个排序的链表

      题目描述:   输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则.   解题思路:   首先需要判断几个特殊情况,即判断输入的两个指针是否为空.如果第一个 ...