INPUT "vvedite kol-vo elementov ", n
DIM z(n)
RANDOMIZE TIMER
PRINT "massiv Z"
FOR i = 1 TO n
z(i) = INT(RND * 20)
PRINT z(i);
NEXT
PRINT
FOR i = 1 TO n
IF z(i) > i THEN k = k + 1: x(k) = z(i)
NEXT
PRINT "massiv X"
FOR i = 1 TO k
PRINT x(i);
NEXT
PRINT
FOR i = 1 TO k
FOR j = 2 TO k
IF x(j) > x(j - 1) THEN SWAP x(j), x(j - 1)
NEXT
NEXT
PRINT "otsortirovannyj massiv"
FOR i = 1 TO k
PRINT x(i);
NEXT
Тестирование выполнено в программе QB64 ( Скачать )