CLS
INPUT "vvedite n"; n
DIM a(n, n)
FOR i = 1 TO n: FOR j = 1 TO n
PRINT "vvedite a ("; i; ","; j; ")";
INPUT a(i, j)
NEXT: NEXT
FOR i = 1 TO n
IF a(i, i) > 0 THEN s = s + a(i, i)
NEXT
FOR i = 1 TO n: FOR j = 1 TO n
PRINT a(i, j);
NEXT: PRINT: NEXT
PRINT STRING$(80, 196); "s ="; s
Тестирование выполнено в программе QB64 ( Скачать )