#include <stdio.h>
#include <string.h>
int main()
{
char temp[20],balloon[1050][20];
int n,i,j,tot,count[1050],max;
bool JG;
while (scanf("%d",&n) != EOF)
{
memset(count,0,1000);
memset(balloon,0,1000);
tot=0;
for(i=1;i<=n;i++)
{
scanf("%s",temp);
JG=false;
for(j=1;j<=tot;j++)
if (strcmp(balloon[j],temp) == 0)
{
JG=true;
count[j]++;
}
if (!JG)
{
tot++;
count[tot]=1;
strcpy(balloon[tot],temp);
}
}
max=-1;
for(i=1;i<=tot;i++)
{
if (max<count[i])
{
max=count[i];
j=i;
}
}
printf("%s\n",balloon[j]);
}
return 0;
}
//用C写的,这代码貌似没什么问题啊。。。。大神们请给我指引吧,跪在上面一小时了。。。
#include <string.h>
int main()
{
char temp[20],balloon[1050][20];
int n,i,j,tot,count[1050],max;
bool JG;
while (scanf("%d",&n) != EOF)
{
memset(count,0,1000);
memset(balloon,0,1000);
tot=0;
for(i=1;i<=n;i++)
{
scanf("%s",temp);
JG=false;
for(j=1;j<=tot;j++)
if (strcmp(balloon[j],temp) == 0)
{
JG=true;
count[j]++;
}
if (!JG)
{
tot++;
count[tot]=1;
strcpy(balloon[tot],temp);
}
}
max=-1;
for(i=1;i<=tot;i++)
{
if (max<count[i])
{
max=count[i];
j=i;
}
}
printf("%s\n",balloon[j]);
}
return 0;
}
//用C写的,这代码貌似没什么问题啊。。。。大神们请给我指引吧,跪在上面一小时了。。。