' $DYNAMIC
DIM X(10) AS INTEGER, Y(10) AS INTEGER, Nom%(10)
CLS
' Заполним массивы
RANDOMIZE TIMER
FOR i = 1 TO 10
X(i) = RND * 21: Y(i) = RND * 21
NEXT
' Массивы на экран
PRINT "X: "; : FOR i = 1 TO 10: PRINT X(i); : NEXT: PRINT
PRINT "Y: "; : FOR i = 1 TO 10: PRINT Y(i); : NEXT: PRINT
' Выводим номера пар X(i)>Y(i)
PRINT "Nomera X(i)>Y(i):"
FOR i = 1 TO 10
IF X(i) > Y(i) THEN Nom%(i) = 1: PRINT i;
NEXT: PRINT
' Сжимаем массив
b = 1
FOR i = 1 TO 10
IF Nom%(i) = 0 THEN
X(b) = X(i): Y(b) = Y(i)
b = b + 1
END IF
NEXT: b = b - 1
' Переопределяем массивы
IF b > 0 THEN
DIM Z(b): FOR i = 1 TO b: Z(i) = X(i): NEXT
REDIM X(b) AS INTEGER
FOR i = 1 TO b: X(i) = Z(i): Z(i) = Y(i): NEXT
REDIM Y(b) AS INTEGER
FOR i = 1 TO b: Y(i) = Z(i): NEXT
ERASE Z
END IF
' Новые массив на экран
PRINT "Novye massivi:"
PRINT " X", " Y"
FOR i = 1 TO b
PRINT X(i), Y(i)
NEXT
DIM x(10), y(10), x1(10), y1(10)
CLS
RANDOMIZE TIMER
FOR i = 1 TO 10
x(i) = INT(RND * 21): y(i) = INT(RND * 21)
NEXT
PRINT "X: "; : FOR i = 1 TO 10: PRINT x(i); : NEXT: PRINT
PRINT "Y: "; : FOR i = 1 TO 10: PRINT y(i); : NEXT: PRINT
PRINT "Nomera X(i)>Y(i):"
FOR i = 1 TO 10
IF x(i) > y(i) THEN PRINT i ELSE k = k + 1: x1(k) = x(i): y1(k) = y(i)
NEXT: PRINT
PRINT "Novye massivi:"
PRINT " X", " Y"
FOR i = 1 TO k
PRINT x1(i), y1(i)
NEXT
Тестирование выполнено в программе QB64 ( Скачать )