HDU--1004 -- Let the Balloon Rise [水] [字符串]
来源:互联网 发布:轻淘客 登录淘宝联盟 编辑:程序博客网 时间:2024/06/05 01:07
Let the Balloon Rise
Total Submission(s): 58975 Accepted Submission(s): 21685
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.
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.
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
5greenredblueredred3pinkorangepink0
Sample Output
redpink
Code:
水水更健康~
#include<stdio.h>#include<string.h>char str[20],s[1010][20];int a[1010];int main(){int n,i,j,k;while(scanf("%d",&n),n){k = -1;for(i=0;i<n;i++)a[i] = 1;for(i=0;i<n;i++){scanf("%s",str);for(j=0;j<=k;j++){if(strcmp(str,s[j])==0) break;}if(j<=k) a[j]++;else {k++;strcpy(s[k],str);}}int max = 1,imax = 0;for(i=0;i<n;i++){if(a[i]>max){max = a[i];imax = i;} }printf("%s\n",s[imax]);}return 0;}
- HDU--1004 -- Let the Balloon Rise [水] [字符串]
- hdu 1004 let the balloon rise(字符串水题)
- HDU-#1004 Let the Balloon Rise(字符串+map)
- hdu 1004 Let the Balloon Rise ( 字符串 ,二维数组)
- hdu 1004 Let the Balloon Rise ( 字符串简单处理)
- HDU 1004 Let the Balloon Rise 字符串操作
- 1004 Let the Balloon Rise【字符串】
- HDOJ 1004 Let the Balloon Rise(字符串)
- HDU 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- HDU--1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- hdu 1004 Let the Balloon Rise
- HDU 1004 Let the Balloon Rise
- iOS中UIPopoverController的使用
- 有关C++中的流操纵算子
- C语言中常用字符串函数锦囊
- mysql group by用法
- spring mvc中org.springframework.web.servlet.DispatcherServlet类
- HDU--1004 -- Let the Balloon Rise [水] [字符串]
- Apache的SVN库(库中含有很多apache的开源项目,接近200个)
- Android自定义View之一
- Spice代码分析(三)——red_worker: red_init
- 编程竞赛技巧:Meet in the middle
- 2013年华为编程大赛上机题
- Spring MVC 3.2 技术预览(一):Servlet 3介绍,异步支持
- c#
- access 标准表达式中数据类型不匹配