MS DOS QBasic 1.0
RANDOMIZE TIMER
CONST n = 9
DIM a(1 TO n) AS INTEGER
CLS
FOR i = 1 TO n
a(i) = INT(99 * RND)
PRINT a(i);
NEXT i
PRINT
FOR i = 1 TO n - 1
FOR j = i + 1 TO n
IF a(i) < a(j) THEN
t = a(i)
a(i) = a(j)
a(j) = t
END IF
NEXT j
NEXT i
FOR i = 1 TO n
PRINT a(i);
NEXT i
Пример
85 21 7 21 29 45 98 70 23
98 85 70 45 29 23 21 21 7