【王道九度OJ】1018 统计同成绩学生人数||hash的应用

本题相对于上一题就很简单了。思路很巧妙 运用hash数组 存放每一个分数的人数,最后直接输出数组中某下标对应分数的值就可以了。

#include<stdio.h>
int main()
{
	int n;
	while( scanf("%d", &n) != EOF && n != 0)
	{
		int Hash[101]={0};
		for(int i=0; i<n; i++)
		{
			int x;
			scanf("%d" , &x);
			Hash[x]++;
		}
		int x;
		scanf("%d",&x);
		printf("%d\n", Hash[x]);
	}
	return 0;
}


你可能感兴趣的:(【王道九度OJ】1018 统计同成绩学生人数||hash的应用)