Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.79 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7.  
  8.     int arrSize;
  9.     cin >> arrSize;
  10.  
  11.     int arr[arrSize] = {0};
  12.  
  13.     for(int k = 0; k < arrSize; ++k)
  14.     {
  15.         cin >> arr[k];
  16.     }
  17.  
  18.  
  19.     int most_Frequent_num = 0;
  20.     int print_index = 0;
  21.     for(int i = 0; i <= arrSize; ++i)
  22.     {
  23.         int counter_Frequent_loop = 0;
  24.        
  25.         for(int j = 0; j <= arrSize; ++j)
  26.         {
  27.             if(arr[i] == arr[j])
  28.             {
  29.                 counter_Frequent_loop++;
  30.             }
  31.             if(most_Frequent_num < counter_Frequent_loop)
  32.             {
  33.                 most_Frequent_num = counter_Frequent_loop;
  34.                 print_index = arr[i];
  35.  
  36.             }
  37.  
  38.         }
  39.        
  40.  
  41.     }
  42.     cout << print_index << endl;
  43.  
  44.  
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement