读入N名同学的成绩,然后将获得某一给定分数的学生人数输出
第一行给出不超过10^5的正整数,即学生总数;
第二行给出N名学生的百分制的成绩,中间以空格分隔;
第三行给出要查寻的分数个数K,随后是K个分数,中间以空格分隔;、
#include<cstdio>
int hashTable[110] = { 0 };
int main() {
int n, k, score;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d", &score);
hashTable[score]++;
}
scanf("%d",&k);
for (int i = 0; i < k; i++) {
scanf("%d", &score);
printf("%d", hashTable[score]);
if (i < k - 1) {
printf(" ");
}
}
return 0;
}