杭电 1004 Let the Balloon Rise
来源:互联网 发布:水果软件可以录歌吗 编辑:程序博客网 时间:2024/05/18 21:47
Let the Balloon Rise
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 68556 Accepted Submission(s): 25432
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
Author
WU, Jiazhi
#include<iostream>#include<cstring>using namespace std;int main(){ int n,i,k,max[1005],j; char a[1005][100],t; while(cin>>n,n) { memset(max,0,sizeof(max)); for(i=0;i<n;i++) cin>>a[i]; for(i=0;i<n;i++) for(j=0;j<n;j++) { if(strcmp(a[i],a[j])==0) max[i]++; } for(i=0,k=0;i<n;i++) { //cout<<max[i]<<endl; if(max[i]>k) k=max[i]; } for(i=0;i<n;i++) { if(max[i]==k) break; } cout<<a[i]<<endl; } return 0;}
0 0
- 杭电 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
- 杭电-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
- 杭电1004 Let the Balloon Rise
- [杭电]Let the Balloon Rise
- 杭电Let the Balloon Rise
- 杭电OJ Let the Balloon Rise
- 杭电problem1004- Let the Balloon Rise
- Let the Balloon Rise(杭电ACM 1004)
- 杭电acm 1004 (Let the Balloon Rise)
- 杭电ACM 1004 “+Let+the+Balloon+Rise”
- 滚动条(如果超出屏幕,自动计算滚动)
- Xcode的控制台调试命令
- ASP.NET上传文件的三种基本方法
- Java编程中“为了性能”需做的26件事(同样适用于Android开发)
- XCode: Target Settings和Project Settings的区别
- 杭电 1004 Let the Balloon Rise
- poj 3411 Paid Roads
- 两次一轮游的一点感想
- initWithCoder/loadView等区别
- 欧拉定理与应用
- oracle 11g导出空表 DEFERRED_SEGMENT_CREATION
- 浅谈DAO工厂设计模式
- Struts2_ValueStack
- 深入理解计算机系统 2.60