' Razmernost
CONST x = 5, y = 5
' Matritsa
DIM M(x, y), MaxEl, MaxY
CLS
' Zapolnim matritsu
RANDOMIZE TIMER ' Zapolnyaem sluch. chislami
M(1, 1) = 1
FOR iy = 1 TO y: FOR ix = 1 TO x
M(ix, iy) = INT(RND * 51) - 25
NEXT: NEXT
' Vivedem yeyo na ekran
PRINT "____Ishodnaya matrica______________________"
FOR iy = 1 TO y: FOR ix = 1 TO x
PRINT M(ix, iy);
NEXT: PRINT: NEXT: PRINT
' Naidyom maksimalnii element vsei matritsi
FOR iy = 1 TO y: FOR ix = 1 TO x
IF M(ix, iy) > MaxEl THEN MaxEl = M(ix, iy): MaxY = iy
NEXT: NEXT
' Yesli v 1 i posl. stroke net maks. el, to menyaem
IF MaxY <> 1 AND MaxY <> y THEN
FOR i = 1 TO x
SWAP M(i, 1), M(i, y)
NEXT
END IF
' Vivedem gotovuyu matritsu na ekran
PRINT "____Novaya matrica_________________________"
FOR iy = 1 TO y: FOR ix = 1 TO x
PRINT M(ix, iy);
NEXT: PRINT: NEXT
Тестирование выполнено в программе QB64 ( Скачать )