Advertisement
ilyaaaaa

Untitled

Sep 23rd, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n;
  6.     cout << "vvedite kol-vo elementov: ";
  7.     cin >> n;
  8.     int* mass = new int[n];
  9.  
  10.    
  11.  
  12.  
  13.     for (int i = 0; i < n; i++)
  14.     {
  15.         cout << "[" << i << "] = ";
  16.         cin >> mass[i];
  17.     }
  18.  
  19.     int maxcount = 0;
  20.     int element;
  21.    
  22.     for ( int i = 0; i < n; i++)
  23.     {
  24.         int count = 0;
  25.         for (int j = i; j < n; j++)
  26.         {
  27.             if (mass[i] == mass[j])
  28.             {
  29.                 count++;
  30.             }
  31.  
  32.  
  33.  
  34.             if (maxcount < count)
  35.             {
  36.                 maxcount = count;
  37.                 element = i;
  38.             }
  39.         }
  40.        
  41.     }
  42.     cout << endl << mass[element] << endl;
  43.  
  44.  
  45.  
  46.     delete[] mass;
  47.     return 0;
  48.  
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement