INPUT "vvedite kol-vo chisel ", n
DIM a(n), b(n - 1)
RANDOMIZE TIMER
FOR i = 1 TO n
a(i) = INT(RND * 50)
NEXT
PRINT "ishodnyj massiv"
FOR i = 1 TO n
PRINT a(i);
NEXT
PRINT
FOR i = 1 TO n - 1
b(i) = a(i + 1) - a(1)
NEXT
PRINT "posledovatelnost"
FOR i = 1 TO n - 1
PRINT b(i);
NEXT
PRINT
FOR i = 1 TO n - 1
FOR j = 2 TO n - 1
IF b(j) < b(j - 1) THEN SWAP b(j), b(j - 1)
NEXT
NEXT
PRINT "uporyadochennaya posledovatelnost"
FOR i = 1 TO n - 1
PRINT b(i);
NEXT
Тестирование выполнено в программе QB64 ( Скачать )