Program zd4;
uses CRT;
type mas=array[1..20,1..20] of real;
var A:mas; g,b,i,j,n,m,nom1,nom2:integer; max:real;
Begin
clrscr;
write ('Введите размер массива: ');
readln (n,m);
write ('Введите диапазон чисел в массиве: ');
readln (g,b);
Randomize;
For i:=1 to n do
Begin
For j:=1 to m do
Begin
A[i,j]:=random(b-g)+g;
write (A[i,j]:5:0,' ');
End;
writeln;
End;
nom1:=1;
nom2:=1;
max:=a[1,1];
For i:=1 to n do
Begin
For j:=1 to m do
Begin
If a[i,j]>max then
Begin
max:=A[i,j];
nom1:=j;
nom2:=i;
End;
End;
End;
writeln ('Максимальный элемент массива= ',max:5:0,' ,его координаты ','[',nom1,',',nom2,']');
readln;
End.
Так?
Sub abcd()
Dim n As Integer, a(1 To 8) As Integer
Dim r As Range
n = 8
imax = 1
Set r = Range(Cells(1, 1), Cells(2, 8))
r.ClearContents 'Очистка области
r.Interior.Color = RGB(255, 255, 255) 'Очистка цвета заливки
For i = 1 To n
a(i) = Int(30 * Rnd)
If a(i) > a(imax) Then imax = i
Cells(1, i) = a(i)
Next
t = a(imax)
Cells(1, imax).Interior.Color = RGB(204, 255, 255)
Range(Cells(1, 1), Cells(1, imax - 1)).Interior.Color = RGB(255, 255, 153)
For i = imax - 1 To 1 Step -1
a(i + 1) = a(i)
Next
a(1) = t
For i = 1 To n
Cells(2, i) = a(i)
Next
Cells(2, 1).Interior.Color = RGB(204, 255, 255)
Range(Cells(2, 2), Cells(2, imax)).Interior.Color = RGB(255, 255, 153)
End Sub