Advertisement
STANAANDREY

e1_4/4/2019

Apr 4th, 2019
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.44 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.  unsigned n,i,v[1000],nr,j,maxi=0;
  7.  cout<<"n=";cin>>n;
  8.  for (i=0;i<n;i++)
  9.  cin>>v[i];
  10. for (i=0;i<n-1;i++)
  11. {
  12.     nr=1;
  13.     for (j=i+1;j<n;j++)
  14.     if (v[i]==v[j])
  15.     nr++;
  16.     if (nr>maxi)
  17.         maxi=nr;
  18. }
  19.  for (i=0;i<n;i++)
  20.  {
  21.      nr=1;
  22.       for (j=i+1;j<n;j++)
  23.      if (v[i]==v[j])
  24.         nr++;
  25.      if (nr==maxi)
  26.         cout<<v[i]<<' ';
  27.  }
  28.     return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement