https://www.patest.cn/contests/pat-b-practise/1038
#include <cstdio> int cnt[110]; int temp[100010]; //k次查询,每次查询的结果都保存了起来 开太小则越界 int main(){ int n,k,t,s = 0; scanf("%d",&n); for(int i = 0;i < n; i++) { scanf("%d",&t); cnt[t]++; } scanf("%d",&k); for(int i = 0;i < k; i++) { scanf("%d",&t); temp[s++] = cnt[t]; } for(int i = 0;i < s; i++) { if(i != 0) printf(" "); printf("%d",temp[i]); } return 0; }