https://www.patest.cn/contests/pat-b-practise/1038 ...
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; }