CLS
INPUT "vvedite razmer massiva"; n
INPUT "vvedite chislo"; k
DIM a(n)
FOR i = 1 TO n
PRINT "vvedite element"; i
INPUT a(i)
NEXT
CLS
PRINT "massiv"
FOR i = 1 TO n
PRINT a(i);
NEXT
FOR i = 1 TO n
IF a(i) MOD k = 0 THEN c = c + 1: SWAP a(i), a(c)
NEXT
FOR i = 1 TO c
FOR j = 2 TO c
IF a(j) < a(j - 1) THEN SWAP a(j), a(j - 1)
NEXT
NEXT
PRINT
PRINT "new massiv"
FOR i = 1 TO n
PRINT a(i);
NEXT
Тестирование выполнено в программе QB64 ( Скачать )