CLS
INPUT "Vvedite imya faila:"; FL$
ON ERROR GOTO CantFind
Fr = FREEFILE
OPEN "I", #Fr, FL$
' Esli Fail est
IF NoFound = 1 THEN
' Esli Faila net
PRINT "FAIL NE NAIDEN!!! VVODIM S KLAVIATURI!!!"
INPUT "Vvedite kol-vo strok : ", m
INPUT "Vvedite kol-vo stolbcov : ", n
ELSEIF NoFound = 0 THEN
INPUT #Fr, m, n
END IF
DIM A(n, m)
ON ERROR GOTO CantRead
FOR iy = 1 TO m: FOR ix = 1 TO n
IF NoFound = 1 THEN
PRINT "Vvedite element [Stroka:" + STR$(iy) + ",Stolbec:" + STR$(ix) + "] :";
INPUT A(ix, iy)
ELSEIF NoFound = 0 THEN
INPUT #Fr, A(ix, iy)
END IF
NEXT: NEXT
IF NoFound = 0 THEN CLOSE #Fr
'Vivod matrici
PRINT "Matrica__________"
FOR iy = 1 TO m: FOR ix = 1 TO n
PRINT A(ix, iy);
NEXT: PRINT: NEXT
PRINT "[S] - Sohranit matricu [N|ESC] - ne sohranit"
DO: c$ = INKEY$:
IF UCASE$(c$) = "S" THEN
'Vivod matrici v fail
Fr = FREEFILE
OPEN "O", #Fr, "Matrica.txt"
PRINT #Fr, m; n
FOR iy = 1 TO m: FOR ix = 1 TO n
PRINT #Fr, A(ix, iy);
NEXT: PRINT #Fr,: NEXT: EXIT DO
CLOSE #Fr
ELSEIF UCASE$(c$) = "N" OR c$ = CHR$(27) THEN EXIT DO
END IF
LOOP
el = A(1, 1)
FOR iy = 1 TO m: FOR ix = 1 TO n
IF A(ix, iy) > el THEN el = A(ix, iy): elx = ix: ely = iy
NEXT ix, iy
SWAP A(1, 1), A(elx, ely)
PRINT "Rezultat_________"
FOR iy = 1 TO m: FOR ix = 1 TO n
PRINT A(ix, iy);
NEXT: PRINT: NEXT
ON ERROR GOTO 0
END
CantFind:
NoFound = 1
RESUME NEXT
CantRead:
FormatER = 1: COLOR 12
PRINT "Oshibka formata faila, ispravte fail!!!"
END
RESUME NEXT
Тестирование выполнено в программе QB64 ( Скачать )