FOR i = 0 TO 9
IF ar(i) > max THEN max = ar(i): maxindex = i
NEXT i
FOR i = 10 TO 24
IF ar(i) < min THEN min = ar(i): minindex = i
NEXT i
tmp = ar(minindex)
ar(minindex) = ar(maxindex)
ar(maxindex) = tmp
FOR i = 0 TO 9
IF ar(i) > max THEN max = ar(i): maxindex = i
NEXT i
FOR i = 10 TO 24
IF ar(i) < min THEN min = ar(i): minindex = i
NEXT i
tmp = ar(minindex)
ar(minindex) = ar(maxindex)
ar(maxindex) = tmp