Advertisement
STANAANDREY

vector de freq

Jun 4th, 2019
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.30 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int v[100],n,m,ap[100],i;
  7. cout<<"n=";cin>>n;
  8. cout<<"m=";cin>>m;
  9. for (i=0;i<m;i++)
  10. ap[i]=i;
  11. for (i=0;i<n;i++)
  12. cin>>v[i];
  13. for (i=0;i<n;i++)
  14. ap[v[i]]++;
  15. for (i=0;i<m;i++)
  16.     cout<<"Elementul "<<i<<" apare de "<<ap[i]<<" ori\n";
  17.   return 0;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement