' Nasha matritsa
DATA 82,36,97,53
DATA 55,32,34,28
DATA 84,94,40,95
DATA -63,-71,-93,-94
' Programma
CLS ' Ochistim ekran
DIM M(4, 4) ' Zavedyom massiv
' iy - nomer stroki, ix - nomer stolbtsa
' Zapolnim massiv v tsikle i vivedem matiritsu na ekran
FOR iy = 1 TO 4: FOR ix = 1 TO 4
READ M(ix, iy) ' Chitaem element iz DATA v massiv
PRINT M(ix, iy); ' Pechataem element na ekran
NEXT: PRINT: NEXT ' Mezhdu NEXT'ov perevod stroki
' Cumma otrits. el. pod diagonalyu.
FOR iy = 1 TO 4: FOR ix = 1 TO 4
IF iy > ix AND M(ix, iy) < 0 THEN Sum = Sum + M(ix, iy)
NEXT: NEXT
' Vivodim rezultat
PRINT "Summa elem. nizhe diagonali:"; Sum
' Srednee arifmeticheskoe el-tov diagonali
Sr = M(1, 1) ' Pervii element v summu
FOR i = 2 TO 4: Sr = Sr + M(i, i): NEXT ' Ostalnie elementi
' Vivodim rezultat
PRINT "Srednee zn. elem. diagonali:"; Sr / 4
Тестирование выполнено в программе QB64 ( Скачать )