fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7.  
  8. int a[100];
  9. for(int i = 0; i < n; i++) {
  10. cin >> a[i];
  11. }
  12.  
  13. int hash[100] = {0};
  14. for(int i = 0; i < n; i++) {
  15. hash[a[i]]++;
  16. }
  17.  
  18. int q;
  19. cin >> q;
  20.  
  21. for(int i = 0; i < q; i++) {
  22. int x;
  23. cin >> x;
  24. cout << hash[x] << " ";
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0.01s 5312KB
stdin
9
1 3 3 4 1 4 4 4 4
3
3 4 1
stdout
2 5 2