STANAANDREY

pb 44 /342

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