c语言 ACM一题Problem DescriptionContest 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
来源:学生作业帮助网 编辑:六六作业网 时间:2024/05/27 10:05:32
c语言 ACM一题Problem DescriptionContest 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
c语言 ACM一题
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
c语言 ACM一题Problem DescriptionContest 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
#include
#include
int main()
{
int num;
while(scanf("%d",&num) == 1 && num)
{
char a[1000][16] = {0},b[16];
int i,l,max = 0,size = 0,count[1000] = {0};
for(i = 0; i < num; i++)
{
scanf("%s",b);
int pd = 1;
for(l = 0; *a[l]; l++)
if(!strcmp(a[l],b)) { count[l]++; pd = 0; break; }
if(pd) { strcpy(a[size],b); count[size++]++; }
}
for( i = 0; *a[i]; i++)
count[i] > max max = count[i],size = i :0;
printf("%s\n",a[size]);
}
return 0;
}