CLS
n = 20
DIM a(n): DIM b(n)
RANDOMIZE TIMER
FOR i = 1 TO n
a(i) = INT(RND * 100) - 50
NEXT i
PRINT "Massiv a(20)"
FOR i = 1 TO n
PRINT a(i);
NEXT i
PRINT
k = 0
FOR i = 1 TO n
IF a(i) > 0 THEN k = k + 1: b(k) = a(i)
NEXT i
s = k: k = 0
FOR i = 1 TO n
IF a(i) < 0 THEN k = k + 1: b(k + s) = a(i)
NEXT i
PRINT "Massiv B(20)"
FOR i = 1 TO n
PRINT b(i);
NEXT i
Тестирование выполнено в программе QB64 ( Скачать )