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