program MinMax(Input,Output); { Program 6.1 - Find the largest and smallest number in a given list. const MaxSize = 20; type ListSize = 1 .. MaxSize; var Item; ListSize; Min, Max, First, Second; Integer; A; array [ListSize] of Integer; begin for Item ;= 1 to MaxSize do begin Read(Input, A[Item]); Write (Output, A[Item] ;4) end; Writeln(Output) ; Min ;= A[l]; Max;= Min; Item;= 2; while Item < MaxSize do begin First ;= A[Item]; Second.- A[Item+l]; if First > Second then begin if First> Max then Max ;= First; if Second < Min then Min ;= Second end else begin if Second> Max then Max ;= Second; if First < Min ~hen Min ;= First end; Item ;= Item + 2 end; if Item = MaxSize then if A[MaxSize] > Max then Max ;= A[MaxSize] else if A[MaxSize] < Min then Min ;= A[MaxSize]; Writeln(Output, Max, Min) end . 

## Produces as results (assuming appropriate input): 

35 68 94 7 88 -5 -3 12 35 74 88 52 43 94 -6 5 4 9 -6 3 o -2 

