Spicke

Project Number 5

Dec 13th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <conio.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     setlocale(LC_ALL, "Russian");
  9.     int e;
  10.     int mas[100];
  11.     cout << "Введите размер массива: ";
  12.     cin >> e;
  13.     for (int a = 0; a < e; a++)
  14.     {
  15.         cin >> mas[a];
  16.     }
  17.     cout << endl;
  18.     for (int a = 0; a < e; a++)
  19.     {
  20.         cout << mas[a] << " ";
  21.     }
  22.     cout << endl;
  23.     int current_max = 0, old_max = 0;
  24.     for (int i = 0; i < e - 1; i++)
  25.     {
  26.         for (int b = 0; b < e; b++)
  27.         {
  28.             if (mas[i] == mas[b])
  29.                 current_max++;
  30.         }
  31.         cout << current_max << endl;
  32.         if (current_max > old_max)
  33.             old_max = current_max;
  34.         current_max = 0;
  35.     }
  36.     cout << "Максимальное количество одинаковых элементов: " << old_max << endl;
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment