作业帮 > 综合 > 作业

c语言 ACM一题Problem DescriptionContest time again!How excited i

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/11 15:08:00
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
#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;
}