1004
来源:互联网 发布:unity3d 双摄像机分屏 编辑:程序博客网 时间:2024/06/05 04:28
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
#include <iostream>#include <string>using namespace std;int main(){ int num; while(cin>>num&&num>0&&num<=1000) { string balloon[10001]; for(int i=0;i<num;i++) cin>>balloon[i]; int count[10001]={0}; for(int i=0;i<num;i++) for(int j=i;j<num;j++) if(balloon[i]==balloon[j]) count[i]++; int maxCount=count[0],e=0; for(int t=0;t<num;t++) if(maxCount<count[t]) { maxCount=count[t]; e=t; } cout<<balloon[e]<<endl; } return 0;}
0 0
- [1004]
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- DHCP协议
- PLC联姻物联网,如何实现工控第二春
- Codeforces Round #404 (Div. 2) D. Anton and School
- 浅谈代码分层:构建模块化程序
- MFC中的DestroyWindow详解
- 1004
- Redis-cli简单操作命令
- 第41天(就业班) jQuery入门
- Oracle的操作系统身份认证
- TensorFlow 变量共享
- 未来的路
- 数据结构之 JavaScript实现栈
- 限制ssh登陆用户目录及命令
- atexit函数