Share your repls and programming experiences

← Back to all posts
6.C. While: Second maximum
pole55 (233)

Given a sequence of distinct non-negative integers, where each number is written in a separate line. The sequence ends with 0. Print the second largest element in this sequence. It is guaranteed that the sequence has at least two elements.

Example input
1
7
9
0

Example output
7