RANDOMIZE timer
n = 6: m = 6
DIM a(n, m)
FOR i = 1 TO n
FOR j = 1 TO m
a(i, j) = INT(RND * 50) - 10
NEXT
NEXT
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j);
NEXT
PRINT
NEXT
FOR i = 1 TO n
f = 0
FOR j = 1 TO m
IF a(i, j) < 0 THEN f = 1
NEXT
func a(), i, m, f
NEXT
PRINT STRING$(80, 196)
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j);
NEXT
PRINT
NEXT
SUB func (a(), n, m, r)
FOR i = 1 TO m - 1
FOR j = 1 TO m - i
IF r THEN
IF a(n, j) > a(n, j + 1) THEN SWAP a(n, j), a(n, j + 1)
ELSE
IF a(n, j) < a(n, j + 1) THEN SWAP a(n, j), a(n, j + 1)
END IF
NEXT
NEXT
END SUB
Тестирование выполнено в программе QB64 ( Скачать )