1038 统计同成绩学生
输入样例:
10
60 75 90 55 75 99 82 90 75 50
3 75 90 88
输出样例:
3 2 0
solution
#include <stdio.h>
int main(){int n, d, k, hash[101] = {0}, a[100000];scanf("%d", &n);for(int i = 0; i < n; i++){scanf("%d", &d);hash[d]++;}scanf("%d", &k);for(int i = 0; i < k; i++)scanf("%d", a + i);for(int i = 0; i < k; i++){printf("%d", hash[a[i]]);if(i != k - 1) printf(" ");}return 0;
}
直接输出也能AC
#include <stdio.h>
int main(){int n, d, k, hash[101] = {0}, t;scanf("%d", &n);for(int i = 0; i < n; i++){scanf("%d", &d);hash[d]++;}scanf("%d", &k);for(int i = 0; i < k; i++){scanf("%d", &t);printf("%d", hash[t]);if(i != k - 1) printf(" ");}return 0;
}