DIM c(1 TO 30) AS SINGLE
DIM fEven AS SINGLE, lOdd AS SINGLE
DEFINT I
RANDOMIZE TIMER
FOR i = 1 TO 30
c(i) = FIX((RND / 0.01))
RANDOMIZE TIMER
NEXT i
fEven = 0
lOdd = 0
FOR i = 1 TO 30
PRINT i; "="; c(i)
IF c(i) MOD 2 = 0 THEN
IF fEven = 0 THEN fEven = i
ELSE
lOdd = i
END IF
NEXT i
PRINT "First Even: "; fEven; "Last Odd: "; lOdd
PRINT
PRINT "After Swap"
SWAP c(fEven), c(lOdd)
FOR i = 1 TO 30
PRINT i; "="; c(i)
NEXT i
END
Тестирование выполнено в программе QB64 ( Скачать )