Skip to content
← Back to Community
6.C. While: Second maximum
Profile icon
pole55

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

Voters
Profile icon
AriannaTrakosas
Profile icon
dasaridurgasesh
Profile icon
BANDHASHARATH
Profile icon
FaizRasool2
Profile icon
ChaosDragonSai
Profile icon
CharushM
Profile icon
tomsfy
Profile icon
nattapon29
Profile icon
cmissett
Profile icon
GoldAlpha3