杭电ACM1004Let the Balloon Rise
来源:互联网 发布:qq for mac历史版本 编辑:程序博客网 时间:2024/06/08 15:02
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 78896 Accepted Submission(s): 29628
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
redpinkC++程序:#include <iostream>#include <string.h>using namespace std;int main(){ int n,i,j,a[1001],flag,max; char s[1001][16]; while(cin>>n) { for(i=0; i<n; i++) cin>>s[i]; for(i=0,max=0; i<n; i++) //max置零 { for(j=i+1,a[i]=0; j<n; j++) //a[i]置零 { if(strcmp(s[i],s[j]) == 0) a[i]++; } if(a[i] > max) //统计出同一字符串出现的最多次数 { max = a[i]; } } for(i=0;i<n;i++) //遍历统计数组,找出同最多次数一样的输出 if(a[i]==max) { cout<<s[i]<<endl; } } return 0;}
0 0
- 杭电ACM1004Let the Balloon Rise
- 杭电 1004[Let the Balloon Rise]
- 杭电 1004 Let the Balloon Rise
- 杭电 1004 Let the Balloon Rise
- [杭电]Let the Balloon Rise
- 杭电Let the Balloon Rise
- 杭电 1004 Let the Balloon Rise
- 杭电1004 Let the Balloon Rise
- 杭电-1004 Let the Balloon Rise
- 杭电1004---Let the Balloon Rise
- 杭电1004-Let the Balloon Rise
- 杭电OJ Let the Balloon Rise
- 【杭电】 1004 Let the Balloon Rise
- 杭电 1004 Let the Balloon Rise
- 杭电problem1004- Let the Balloon Rise
- 杭电1004 Let the Balloon Rise
- Let the Balloon Rise(杭电ACM 1004)
- 杭电acm 1004 (Let the Balloon Rise)
- 使用c# 5分钟 创建一个Roguelike 游戏
- ACM模板整理
- Python text file processing
- C#显示时间怎么变成24小时制的
- 【Matlab】 RGB照片转化成灰度图叠加显示
- 杭电ACM1004Let the Balloon Rise
- mybatis返回List<Object[]>数据
- GifView——Android显示GIF动画的扩展控件
- shell——tr的用法
- 2014.12.16窗口适应屏幕大小
- 第十六周项目3--用函数指针调用函数
- 语料预处理
- 设置vmware虚拟机从U盘启动pe系统
- windows php 错误: openssl_pkey_export(): cannot get key from parameter 1