CLS
INPUT "Razmer matrici:", m
DIM Q(m, m), Sum
' Generiruem maricu
RANDOMIZE TIMER
FOR iy = 1 TO m: FOR ix = 1 TO m
Q(ix, iy) = INT(RND * 101) - 50
PRINT Q(ix, iy);
NEXT: PRINT: NEXT: PRINT
' Ishem otric elementy, skladivajem i zapisyvajem
' na mesto glavnoj diagonali
FOR iy = 1 TO m
FOR ix = 1 TO m
IF Q(ix, iy) < 0 THEN Sum = Sum + Q(ix, iy)
NEXT
Q(iy, iy) = Sum: Sum = 0
NEXT
' Rezultat
FOR iy = 1 TO m: FOR ix = 1 TO m
PRINT Q(ix, iy);
NEXT: PRINT: NEXT