~~~
/*
时间:
2013.03.26
作者:
烟大洋仔
题目:
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.
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.
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
5
green
red
blue
red
red
3
pink
orange
pink
0
Sample Output
red
pink
题目分析:
该题目的意思为:让你输入固定个数的颜色然后统计输入颜色最多的颜色名称
*/
#include <iostream>
#include <string.h>
using namespace std;
int main(){
int n,a[1000],max,i;
char s[1000][16];
while (cin>>n&&n!=0)
{
for (i=0;i<n;i++)
cin>>s[i];
for(i=0,max=0;i<n;i++)
{
a[i]=0;
for(int j=i+1;j<n;j++)
{
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;
}
~~~
- 前言
- 求和的问题ACM
- A+B问题acm
- 1091ACM求和
- 杭电ACM1092求和问题详解
- ACM杭电的1093求和问题
- 杭电ACM1094计算A+B的问题
- 杭电ACM1095解决A+B问题
- 杭电ACM1096求和问题
- 杭电Acm1001解决求和的问题
- 杭电ACM1008电梯问题C++
- 杭电ACM大赛2000关于ASCII码排序的问题
- 杭电ACM2006奇数的乘积
- 杭电ACM数值统计2008
- 杭电ACM1019求最大公约数
- 杭电ACM1108求最小公倍数
- 杭电ACM2035人见人爱的A^B
- 杭电ACM1061N^N求最右边的数的问题
- 杭电ACM1021裴波纳挈数AGAIN
- 杭电ACm1005求f(n)非递归
- 杭电ACM1071The area---------求积分面积
- 杭电ACM吃糖果问题
- 杭电ACm求数列的和2009
- 杭电ACM多项式求和--》2011
- 杭电ACM。。。sort
- 杭电ACM1004
- 杭电ACM2043密码的问题已经AC
- 杭电ACM2041楼梯问题
- 动态规划C++::杭电ACM1003
- 杭电ACM----2018母牛的故事
- 杭电ACM2007平方和与立方和
- 卢卡斯队列
- 全国软件2. 三人年龄
- 全国软件3. 考察团组成
- 全国软件--微生物增殖
- 全国软件填写算式
- 全国软件-----------猜生日
- 全国软件---------欧拉与鸡蛋
- Java经典算法四十例编程详解+程序实例
- 杭电ACMA + B Problem II问题解析
- 杭电ACM1018BigNumber解析
- 杭电ACM1088 Write a simple HTML Browser Java
- 杭电ACM1106排序Java代码
- 杭电ACM 1012 u Calculate e java
- 杭电ACM 1020 Encoding java解析
- 杭电1047 An Easy Task - java 解读
- 杭电ACM 1040 As Easy As A+B java 解读
- 杭电ACM 1041 Computer Transformation java代码详解AC
- 杭电ACM 1030 Delta-wave java代码解析