L - Второй максимум
unknown
c_cpp
2 years ago
495 B
15
Indexable
#include <bits/stdc++.h>
using namespace std;
int main() {
int max1, max2;
cin >> max1 >> max2;
if (max1 < max2) {
swap(max1, max2);
}
while (true) {
int x;
cin >> x;
if (x == 0) {
break;
}
if (x >= max1) {
max2 = max1;
max1 = x;
} else if (x > max2) {
max2 = x;
}
}
cout << max2;
return 0;
}
Editor is loading...
Leave a Comment