Advertisement
SeriousVenom

Untitled

Dec 23rd, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.70 KB | None | 0 0
  1.  
  2. #include "pch.h"
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int size = 0, max = 0, max2 = 0;
  10.     cout << "Enter the size of array >> ";
  11.     cin >> size;
  12.     int *mas = new int[size];
  13.     int *mas2 = new int[size];
  14.     for (int i = 0; i < size; i++)
  15.     {
  16.         cin >> mas[i];
  17.     }
  18.     for (int i = 0; i < size; i++)
  19.     {
  20.         if (max < mas[i]) max = mas[i];  // Находи самый большой элемент массива
  21.        
  22.     }
  23.     for (int i = 0; i < (size - 1); i++)
  24.     {
  25.         if (max2 < mas2[i] && max2!=max) max2 = mas2[i];  // Находим второе по величине число
  26.     }
  27.  
  28.     cout << endl;
  29.     cout << "First max = " << max << endl;
  30.     cout << "Second max = " << max2 << endl;
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement