: :
: :
: : start
: : read Largest // algorithm assumes n >= 2
: : read Second
: : if Second > Largest // swap
: : S = Largest
: : Largest = Second
: : Second = S
: : for i = 2 to n
: : read S
: : if (S > Largest) and (S > Second)
: : Second = Largest
: : Largest + S
: : else if S > Second
: : Second = S
: : write Largest, Second
: : stop
: :
: :
: :
:
: The only thing I would change is remove the (S > Second) in the
: first part of the if statement since an invariant of the for loop is
: that Largest > Second.
:
:
:
Right. And the line
Largest + S
is a typo that should be
Largest = S