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 * 100) - 50
NEXT j
NEXT i
FOR i = 1 TO n
FOR j = 1 TO m
PRINT a(i, j);
NEXT j
PRINT
NEXT i
PRINT
s1 = 0: s2 = 0
FOR i = 1 TO n
FOR j = 1 TO m
IF i < j THEN s1 = s1 + a(i, j)
IF i > j THEN s2 = s2 + a(i, j)
NEXT j
NEXT i
PRINT "Summa elementov nad glavnoy diagon="; s1
PRINT "Summa elementov pod glavnoy diagon="; s2
END
Тестирование выполнено в программе QB64 ( Скачать )