DATA -1,-6,3,7,8,-2,4,1,5,-8,6,2,-5,-7,9,4,-3,-9
n = 18
DIM a(n)
PRINT "ishodnyj massiv"
FOR i = 1 TO n
READ a(i)
PRINT a(i);
NEXT
PRINT
FOR i = 1 TO n
FOR j = 2 TO n
IF a(j) < a(j - 1) THEN SWAP a(j), a(j - 1)
NEXT
NEXT
FOR i = 1 TO n - 1
IF a(i) > 0 AND a(i) = a(i + 1) - 1 THEN k = k + 1: b(k) = a(i)
NEXT
IF a(n) > 0 AND a(n - 1) = a(n) - 1 THEN k = k + 1: b(k) = a(n)
PRINT "movyj massiv"
FOR i = 1 TO k
PRINT b(i);
NEXT
Тестирование выполнено в программе QB64 ( Скачать )