матрица заполняется случайно
программа на pascalabc
Var
max,min,mina,minb,maxa,maxb,a,b,c: integer;
mas: array[1..3,1..3] Of integer;
Begin
writeln('до :');
For a:=1 To 3 Do
For b:=1 To 3 Do
mas[a,b] := random(100);
If mas[a,b]>max Then
max := mas[a,b];
maxa := a;
maxb := b;
End;
If (min=0)Or(mas[a,b]<min) Then
min := mas[a,b];
mina := a;
minb := b;
write(mas[a,b],' ');
c := mas[maxa,maxb];
mas[maxa,maxb] := mas[mina,minb];
mas[mina,minb] := c;
writeln;
writeln('после :');
Var a:array [0..2,0..2] of integer;
Position:array[0..1,0..1] of byte;
i,j,max,min:integer;
Procedure print(a:array of array of integer);
For i:integer:=low(a) to high(a) do begin
For j:integer:=low(a[i]) to high (a[i]) do
Write(a[i,j],' ');
Writeln;
Max:=integer.minvalue;
min:=integer.maxvalue;
for i:=low(a) to high(a) do
For j:=low(a[i]) to high(a[i]) do
A[i,j]:=random(10);
Print(a);
If (a[i,j]<min) then begin
Min:=a[i,j]; position [0,0]:=i; position [0,1]:=j;
If (a[i,j]>max) then begin
Max:=a[i,j]; position [1,0]:=i; position [1,1]:=j;
Swap(a[position[0,0], position [0,1]],a[position [1,0]],a[position [1,1]]);
End.
матрица заполняется случайно
программа на pascalabc
Var
max,min,mina,minb,maxa,maxb,a,b,c: integer;
mas: array[1..3,1..3] Of integer;
Begin
writeln('до :');
For a:=1 To 3 Do
For b:=1 To 3 Do
Begin
mas[a,b] := random(100);
If mas[a,b]>max Then
Begin
max := mas[a,b];
maxa := a;
maxb := b;
End;
If (min=0)Or(mas[a,b]<min) Then
Begin
min := mas[a,b];
mina := a;
minb := b;
End;
write(mas[a,b],' ');
End;
c := mas[maxa,maxb];
mas[maxa,maxb] := mas[mina,minb];
mas[mina,minb] := c;
writeln;
writeln('после :');
For a:=1 To 3 Do
For b:=1 To 3 Do
write(mas[a,b],' ');
Var a:array [0..2,0..2] of integer;
Position:array[0..1,0..1] of byte;
i,j,max,min:integer;
Procedure print(a:array of array of integer);
Begin
For i:integer:=low(a) to high(a) do begin
For j:integer:=low(a[i]) to high (a[i]) do
Write(a[i,j],' ');
Writeln;
End;
End;
Begin
Max:=integer.minvalue;
min:=integer.maxvalue;
for i:=low(a) to high(a) do
For j:=low(a[i]) to high(a[i]) do
A[i,j]:=random(10);
Print(a);
for i:=low(a) to high(a) do
For j:=low(a[i]) to high(a[i]) do
Begin
If (a[i,j]<min) then begin
Min:=a[i,j]; position [0,0]:=i; position [0,1]:=j;
End;
If (a[i,j]>max) then begin
Max:=a[i,j]; position [1,0]:=i; position [1,1]:=j;
End;
End;
Swap(a[position[0,0], position [0,1]],a[position [1,0]],a[position [1,1]]);
Print(a);
End.