Advertisement
Five_NT

[C++]Vectorul de frecventa

Jan 13th, 2014
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <iostream.h>
  2.  
  3. int n, f[100], v[100];
  4.  
  5. void citire()
  6. {
  7.     cin>>n;
  8.     for(int i=1; i<=n; i++)
  9.         cin>>v[i];
  10. }
  11.  
  12. void prog(int v[100], int f[10], int n)
  13. {
  14.     for(int j=0; j<=9; j++)
  15.     {
  16.         f[j]=0;
  17.     }
  18.     for(int i=1; i<=n; i++)
  19.     {
  20.         f[v[i]]++;
  21.     }
  22. }
  23. int main()
  24. {
  25.     citire();
  26.     prog(v,f,n);
  27.     for(int i=0; i<=9; i++)
  28.         cout<<" * Cifra "<<i<<" apare de "<<f[i]<<" ori."<<endl;
  29.     return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement