|
zadach84.BAS |
|
{* Задача84 *}REM basic ' Дан массив A (6, 6), состоящий из случайных трехзначных чисел. Поменять местами максимальный и минимальный элемент массива.CLS
Dim A(6, 6) As Integer
RANDOMIZE TIMER
For iy = 1 To 6
For ix = 1 To 6
A(ix, iy) = RND * 899 + 100
PRINT A(ix, iy);
Next: PRINT
Next
Min = 1000
Max = 0
For iy = 1 To 6
For ix = 1 To 6
If A(ix, iy) > Max Then Max = A(ix, iy): Xma = ix: Yma = iy
If A(ix, iy) < Min Then Min = A(ix, iy): Xmi = ix: Ymi = iy
Next ix, iy
PRINT " Max ="; Max; " poziciya: ("; Xma; ","; Yma; ")"
PRINT " Min ="; Min; " poziciya: ("; Xmi; ","; Ymi; ")"
SWAP A(Xma, Yma), A(Xmi, Ymi)
PRINT "Novaya matrica :"
For iy = 1 To 6
For ix = 1 To 6
PRINT A(ix, iy);
Next: PRINT
Next
End
|