hdu1004

时间:2022-05-30
本文章向大家介绍hdu1004,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

//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]); }

	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;

}