CLS
DO
INPUT "vvedite kol-vo strok ", m
INPUT "vvedite kol-vo stolbcov ", n
IF m <> n THEN PRINT "matrica ne kvadratnaya povtorite vvod"
LOOP UNTIL m = n
DIM a(m, n)
FOR i = 1 TO m
FOR j = 1 TO n
PRINT "vvedite element a("; i; ","; j; ")=";
INPUT a(i, j)
NEXT
NEXT
PRINT "matrica"
FOR i = 1 TO m
FOR j = 1 TO n
PRINT a(i, j);
NEXT
PRINT
NEXT
PRINT "glavnaya diagonal"
max = a(1, 1)
FOR i = 1 TO n
PRINT a(i, i);
IF a(i, i) > max THEN max = a(i, i): k = i
NEXT
PRINT
PRINT "maximalnyj element glavnoj diagonali="; max
PRINT "on nahoditsya v stroke nomer "; k
PRINT "stroka nomer "; k
FOR i = 1 TO m
PRINT a(k, i);
NEXT
Следующий вариант
CLS
DO
INPUT "vvedite kol-vo strok ", m
INPUT "vvedite kol-vo stolbcov ", n
IF m <> n THEN PRINT "matrica ne kvadratnaya povtorite vvod"
LOOP UNTIL m = n
DIM a(m, n)
RANDOMIZE TIMER
FOR i = 1 TO m
FOR j = 1 TO n
a(i, j) = INT(RND * 20)
NEXT
NEXT
PRINT "matrica"
FOR i = 1 TO m
FOR j = 1 TO n
PRINT a(i, j);
NEXT
PRINT
NEXT
PRINT "glavnaya diagonal"
max = a(1, 1)
FOR i = 1 TO n
PRINT a(i, i);
IF a(i, i) > max THEN max = a(i, i): k = i
NEXT
PRINT
PRINT "maximalnyj element glavnoj diagonali="; max
PRINT "on nahoditsya v stroke nomer "; k
PRINT "stroka nomer "; k
FOR i = 1 TO m
PRINT a(k, i);
NEXT
Тестирование выполнено в программе QB64 ( Скачать )