1004
来源:互联网 发布:孕囊数据两个一样 编辑:程序博客网 时间:2024/05/20 23:07
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>using namespace std;#define MAX_SIZE 1000int main(){int n,i,j,max,sub;char col[16];while(cin>>n && n!=0){int count[MAX_SIZE];char colour[MAX_SIZE][20];int size=0;max=sub=0;for (i=0;i<n;i++){cin>>col;for (j=0;j<size;j++){if (strcmp(colour[j],col)==0){count[j]++;break;}}if (j==size){strcpy(colour[j],col);count[j]=1;size++; //由于自己粗心,最开始忘了这句!}if(count[j]>max){max=count[j];sub=j;}}cout<<colour[sub]<<endl;}return 0;}
- [1004]
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- 1004
- java设计模式之简单工厂模式
- error: No curses/termcap library found的解决办法
- jquery 操作iframe的几种方法
- 在ThinkPHP中开启调试模式
- 判断手机网络连接状态
- 1004
- Hadoop环境搭建-单节点
- sharepoint网站应用程序池关闭问题
- UltraEdit找不到idm_tidylib.dll文件
- mysql null排序
- v4l2驱动摄像头 出现错误UINT64_C' was not declared in this scope 解决
- 驱动程序开发学习(三)hello world
- 杂想之我的时间安排
- java中String Date Timestamp Calendar 之间的关系及转换