CLS
INPUT "vv. kol-vo strok ", n
INPUT "vv. kol-vo stolbcov ", m
DIM a(n, m)
RANDOMIZE TIMER
FOR i = 1 TO n
FOR j = 1 TO m
a(i, j) = INT(RND * 20) - 10
NEXT
NEXT
PRINT "massiv"
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j); " ";
NEXT
PRINT
NEXT
FOR i = 1 TO n
f = 0
max = a(i, 1)
nom = 1
FOR j = 1 TO m
IF a(i, j) > max THEN max = a(i, j): nom = j
IF a(i, j) < 0 THEN nom1 = j: f = 1
NEXT
FOR k = m TO 1 STEP -1
IF a(i, k) < 0 THEN nom2 = k: IF f = 1 THEN f = 2
NEXT
IF f = 2 THEN a(i, nom) = (a(i, nom1) + a(i, nom2)) / 2
NEXT
PRINT "novyj massiv"
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j); " ";
NEXT
PRINT
NEXT