杭电 1004[Let the Balloon Rise]
来源:互联网 发布:淘宝拍照用什么软件 编辑:程序博客网 时间:2024/05/24 15:39
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
我居然被这种水题绊了大半天……好吧,我现在贴上我半天都不能AC的代码。
#include <iostream>#include <string>using namespace std;void main(){ int n,i,j,max; while(cin>>n&&n!=0) { string str[1000], color; max=0; for(i=0;i<1000;i++) str[i]=""; int num[1000]={0}; for( i=1;i<=n;i++) { cin>>color; for( j=1;j<i;j++) { if(str[j].compare(color)==0 ) { num[j]++; break; } } if(j==i) { str[i]=color; num[i]++; } } for(i=1;i<=n ;i++) { if(num[i]>num[max]) { max=i; } } cout<<str[max]<<endl; }}
真是气得吐血哈哈。
- 杭电 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”
- 虚函数在对象中的内存布局
- 完整的抽屉式工具实现
- ANSI UNICODE的使用
- c# 软件皮肤自定义
- 各种字符串Hash函数比较
- 杭电 1004[Let the Balloon Rise]
- 无线网络破解________破解wap密码..............
- 集线器,路由器,交换机的作用和区别是什么以及如何区分?
- opencv 图像阴影检测
- spserver学习之三__通讯模型
- 俄罗斯方块
- linux grep用法
- C语言数据结构中链表的具体实现
- 2012年3月8日C++学习笔记