CLS
RANDOMIZE TIMER
n = 20
DIM r(n)
FOR i = 1 TO n: r(i) = FIX(RND * 101 - 50): NEXT
FOR i = 1 TO n
PRINT r(i);
NEXT
PRINT STRING$(80, 196)
FOR i = 1 TO n
IF r(i) > 0 THEN s1 = s1 + r(i)
IF r(i) < 0 THEN s2 = s2 + r(i)
NEXT
PRINT "s1="; s1, "s2="; s2
PRINT STRING$(80, 196)
IF ABS(s1) > ABS(s2) THEN
max = r(1)
FOR i = 1 TO n
IF r(i) > max THEN max = r(i)
NEXT
PRINT "max ="; max
ELSE
DIM c(n)
FOR i = 1 TO n
c(i) = r(i) / s1
NEXT
FOR i = 1 TO n
PRINT c(i);
NEXT
END IF
Тестирование выполнено в программе QB64 ( Скачать )