INPUT "vvedite razmer matricy N ", n
DIM b(n, n)
RANDOMIZE TIMER
PRINT "massiv"
FOR i = 1 TO n
FOR j = 1 TO n
b(i, j) = INT(RND * 100) - 50
PRINT b(i, j);
NEXT
PRINT
NEXT
FOR i = 1 TO n
IF b(i, i) > 0 THEN s = s + b(i, i)
NEXT
PRINT "summa polojitelnyh na gl. diagonali="; s
Тестирование выполнено в программе QB64 ( Скачать )