Advertisement
Josif_tepe

Untitled

Feb 9th, 2021
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int n;
  8.     cin >> n;
  9.     int niza[n + 1];
  10.    
  11.     int cnt[1001];
  12.     for(int i = 0; i < 1000; i++) {
  13.         cnt[i] = 0;
  14.     }
  15.     for(int i = 0; i < n; i++) {
  16.         cin >> niza[i];
  17.         cnt[niza[i]]++;
  18.     }
  19.     int maks = 0, broj = 0;
  20.     for(int i = 0; i < 1000; i++) {
  21.         if(maks < cnt[i]) {
  22.             maks = cnt[i];
  23.             broj = i;
  24.         }
  25.     }
  26.     cout << broj << endl;
  27.    
  28.     return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement