Получить упорядоченную не по возрастанию последовательность, состоящую из тех членов первой последовательности, которых нет во второй — Basic(Бейсик)

INPUT "vvedite kol-vo elementov 1 ryada ", n
DIM a(n)
INPUT "vvedite kol-vo elementov 2 ryada ", m
DIM b(m)
RANDOMIZE TIMER
FOR i = 1 TO n
a(i) = INT(RND * 50)
NEXT
PRINT "ryad 1"
FOR i = 1 TO n
PRINT a(i);
NEXT
PRINT
FOR i = 1 TO m
b(i) = INT(RND * 50)
NEXT
PRINT "ryad 2"
FOR i = 1 TO m
PRINT b(i);
NEXT
DIM c(m + n)
PRINT
FOR i = 1 TO n
f = 0
FOR j = 1 TO m
IF a(i) = b(j) THEN f = 1
NEXT
IF f = 0 THEN k = k + 1: c(k) = a(i)
NEXT
FOR i = 1 TO k
FOR j = 2 TO k
IF c(j) > c(j - 1) THEN SWAP c(j), c(j - 1)
NEXT
NEXT
PRINT "ryad 3"
FOR i = 1 TO k
PRINT c(i);
NEXT

Leave a Comment