Let the Balloon Rise
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 4 Accepted Submission(s) : 3
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
This year, they decide to leave this lovely job to you.
Input
A test case with N = 0 terminates the input and this test case is not to be processed.
Output
Sample Input
5 green red blue red red 3 pink orange pink 0
Sample Output
red pink
Author
Source
ZJCPC2004
我的程序:
#include<stdio.h>
#include<string.h>
int main()
{
char co[1001][16];
int i, num, max, j, sum[1001];
char temp[16];
while(1)
{
memset(sum, 0, sizeof(sum));
max = 0;
scanf("%d", &num);
if(num)
{
for(i=0; i < num; ++i)
{
scanf("%s", temp);
for(j=0; j<i; j++)
if(strcmp(co[j], temp) == 0)break;
if(j >= i)
strcpy(co[j], temp);
sum[j]++;
if(sum[max] < sum[j]) max = j;
}
printf("%s\n", co[max]);
}
else break;
}
return 0;
}