Advertisement
Guest User

Example

a guest
Aug 20th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     const int N = 10;
  7.    
  8.     int count[1001];
  9.     for (int i = 0; i <= 1000; i++)
  10.         count[i] = 0;
  11.    
  12.     for (int i = 0; i < N; i++){
  13.         int x;
  14.         cin >> x;
  15.         count[x]++;
  16.     }
  17.     int max = 0, index = 0;
  18.     for (int i = 0; i <= 1000; i++)
  19.         if (count[i] > 0 && count[i] > max){
  20.             max = count[i];
  21.             index = i;
  22.         }
  23.    
  24.     cout << index;
  25.    
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement