hdu1004

2018-06-04 10:50:54 浏览数 (1)

//c //https://github.com/WEIZIBIN/acm/blob/master/hdu1004.c #include <stdio.h> #include <string.h> int main() { int i, n, j; char s[1005][15]; int count[1005] = {0}; while(scanf("%d", &n) != EOF && n != 0) { int max = -1; int maxIndex = -1; memset(count,0,sizeof(count)); for (i = 0; i < n; i) { scanf("%s", s[i]); }

代码语言:javascript复制
	for (i = 0; i < n;   i)
	{
		for (j = 0; j < n;   j)
		{
			if(s[i][0] != '')
			{
				if (i != j)
				{
					if (s[j][0] != '')
					{
						if (strcmp(s[i], s[j]) == 0)
						{
							count[i]  ;
							s[j][0] = '';
						}
					}
				}
			}
			else
				i  ;
		}
	}
	for (i = 0; i < n;   i)
	{
		if(count[i] > max)
		{
			max = count[i];
			maxIndex = i;
		}
	}
	printf("%sn", s[maxIndex]);
}
return 0;

}

0 人点赞