Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- using namespace std;
- int main()
- {
- int size = 0, max = 0, max2 = 0;
- cout << "Enter the size of array >> ";
- cin >> size;
- int *mas = new int[size];
- int *mas2 = new int[size];
- for (int i = 0; i < size; i++)
- {
- cin >> mas[i];
- }
- for (int i = 0; i < size; i++)
- {
- if (max < mas[i]) max = mas[i]; // Находи самый большой элемент массива
- }
- for (int i = 0; i < (size - 1); i++)
- {
- if (max2 < mas2[i] && max2!=max) max2 = mas2[i]; // Находим второе по величине число
- }
- cout << endl;
- cout << "First max = " << max << endl;
- cout << "Second max = " << max2 << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement