fork download
  1. #include <iostream>
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. int main() {
  6. // your code goes here
  7. int n ; cin>>n;
  8. vector<int>arr(n);
  9. for(int i =0;i<n;i++){
  10. cin>>arr[i];
  11. }
  12. for(int i =0;i<n;i++){
  13.  
  14. int count =0;
  15. for(int j =0;j<n;j++){
  16. if(arr[i]==arr[j]) count++;
  17. }
  18. cout<<"count of"<<arr[i]<<" is "<<count<<endl;
  19. }
  20. return 0;
  21. }
  22.  
  23.  
  24.  
Success #stdin #stdout 0.01s 5288KB
stdin
10

1 4 5 6 2 3 4 1 6 6
stdout
count of1 is 2
count of4 is 2
count of5 is 1
count of6 is 3
count of2 is 1
count of3 is 1
count of4 is 2
count of1 is 2
count of6 is 3
count of6 is 3