Дана матрица А(n,n). Переставить местами max и min элементы- Basic(Бейсик)

INPUT"vvedite razmer matricy N ",n
DIM a(n, n)
RANDOMIZE TIMER
PRINT "ishodnaya matrica"
FOR i = 1 TO n
FOR j = 1 TO n
a(i, j) = INT(RND * 100)
PRINT a(i, j);
NEXT
PRINT
NEXT
imin = 1
jmin = 1
imax = 1
jmax = 1
FOR i = 1 TO n
FOR j = 1 TO n
IF a(i, j) < a(imin, jmin) THEN imin = i: jmin = j
IF a(i, j) > a(imax, jmax) THEN imax = i: jmax = j
NEXT
NEXT
PRINT "min=a("; imin; ", "; jmin; ")"
PRINT "max=a("; imax; ", "; jmax; ")"
SWAP a(imin, jmin), a(imax, jmax)
PRINT "novya matrica"
FOR i = 1 TO n
FOR j = 1 TO n
PRINT a(i, j);
NEXT
PRINT
NEXT

Leave a Comment