CONST n = 5 'Razmernost kv. matritsi
DIM M(n, n) 'Matritsa 5x5
DIM Summ 'Summa iskomikh elementov
' Zapolnim yeyo sluchainimi chislami
RANDOMIZE TIMER
FOR ix = 1 TO n
FOR iy = 1 TO n
M(ix, iy) = INT(RND * 11) - 5
NEXT
NEXT
' Ishchem summu krainikh el-ov
FOR i = 1 TO n
Summ = Summ + M(i, 1)
Summ = Summ + M(i, n)
NEXT
FOR i = 2 TO n - 1
Summ = Summ + M(1, i)
Summ = Summ + M(n, i)
NEXT
M(1, 1) = Summ
PRINT "Summa krajnyh elementov:"; Summ
Тестирование выполнено в программе QB64 ( Скачать )