Добавил:
TheBazilius
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:1 семестр сессия / 13
.pas Program Lab_426_Var13;
Type Massive = Array [1..3,1..4] Of Real;
Procedure Poisk(A:Massive; J1,J2:Integer; Var Nom1,Nom2:Integer);
Var I,J:Integer;
Min:Real;
Begin
Min:=A[1,J1];
Nom1:=1;
Nom2:=J1;
For I:=2 To 3 Do
For J:=J1 To J2 Do
If Min>A[I,J] Then
Begin
Min:=A[I,J];
Nom1:=I;
Nom2:=J;
End;
Writeln;
End;
Var
I,J,J1,J2,Ni1,Ni2,Nj1,Nj2,Nom1,Nom2:Integer;
Min:Real;
A:Massive;
Begin
Randomize;
For I:=1 To 3 Do
Begin
For J:=1 To 4 Do
Begin
A[I,J]:=Random(21) - 10;
Write(A[I,J],' ');
End;
Writeln;
End;
Writeln;Writeln('posle perastanovki : ');Writeln;
J1:=1; J2:=2;
Poisk(A,J1,J2,Nom1,Nom2);
Ni1:=Nom1; Nj1:=Nom2;
J1:=3; J2:=4;
Poisk(A,J1,J2,Nom1,Nom2);
Ni2:=Nom1; Nj2:=Nom2;
Min:=A[Ni1,Nj1];
A[Ni1,Nj1]:=A[Ni2,Nj2];
A[Ni2,Nj2]:=Min;
For I:=1 To 3 Do
Begin
For J:=1 To 4 Do
Write(A[I,J],' ');
Writeln;
End;
End.
Type Massive = Array [1..3,1..4] Of Real;
Procedure Poisk(A:Massive; J1,J2:Integer; Var Nom1,Nom2:Integer);
Var I,J:Integer;
Min:Real;
Begin
Min:=A[1,J1];
Nom1:=1;
Nom2:=J1;
For I:=2 To 3 Do
For J:=J1 To J2 Do
If Min>A[I,J] Then
Begin
Min:=A[I,J];
Nom1:=I;
Nom2:=J;
End;
Writeln;
End;
Var
I,J,J1,J2,Ni1,Ni2,Nj1,Nj2,Nom1,Nom2:Integer;
Min:Real;
A:Massive;
Begin
Randomize;
For I:=1 To 3 Do
Begin
For J:=1 To 4 Do
Begin
A[I,J]:=Random(21) - 10;
Write(A[I,J],' ');
End;
Writeln;
End;
Writeln;Writeln('posle perastanovki : ');Writeln;
J1:=1; J2:=2;
Poisk(A,J1,J2,Nom1,Nom2);
Ni1:=Nom1; Nj1:=Nom2;
J1:=3; J2:=4;
Poisk(A,J1,J2,Nom1,Nom2);
Ni2:=Nom1; Nj2:=Nom2;
Min:=A[Ni1,Nj1];
A[Ni1,Nj1]:=A[Ni2,Nj2];
A[Ni2,Nj2]:=Min;
For I:=1 To 3 Do
Begin
For J:=1 To 4 Do
Write(A[I,J],' ');
Writeln;
End;
End.