CLS
INPUT "Kolvo strok="; n
INPUT "Kolvo stolbcov="; m
DIM a(n, m)
RANDOMIZE TIMER
FOR i = 1 TO n
FOR j = 1 TO m
a(i, j) = INT(RND * 101) - 50
NEXT j
NEXT i
PRINT "Ishodniy massiv"
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j);
NEXT j
PRINT
NEXT i
FOR i = 1 TO n
s = 0
FOR j = 1 TO m
IF a(i, j) < 0 THEN s = s + a(i, j)
NEXT j
IF i <= m THEN a(i, i) = s
NEXT i
PRINT
PRINT "Massiv posle preobrazovaniy"
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j);
NEXT j
PRINT
NEXT i
Тестирование выполнено в программе QB64 ( Скачать )