Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define FIO \
- ios_base::sync_with_stdio(false); \
- cin.tie(NULL); \
- cout.tie(NULL);
- int main()
- {
- FIO;
- int n;
- cin >> n;
- int max = INT_MIN, secondMax = INT_MIN;
- int num;
- int count = 1;
- while (count <= n)
- {
- cin >> num;
- if (num > max)
- {
- secondMax = max;
- max = num;
- }
- else if (num > secondMax && num != max)
- {
- secondMax = num;
- }
- count++;
- }
- cout << secondMax << endl;
- }
Add Comment
Please, Sign In to add comment