Const
N = 13;
Var
A:array[1..N] of integer;
i,j,k:integer;
Begin
Randomize;
WriteLn('Исходный массив:');
For i:= 1 to N do
Begin
A[i]:=random(21)-10;
Write(A[i]:4)
End;
WriteLn;
Write('Перестановки:');
k:=N;
i:=1;
Repeat
if A[i]<0 then<br> Begin
While A[k]<0 do<br> k:=k-1;
if k>i then
Begin
Swap(A[i],A[k]);
k:=k-1;
WriteLn;
For j:= 1 to N do
Write(A[j]:4)
End
End;
i:=i+1
Until i>=k;
i:=1;
Repeat
if A[i]=0 then
Begin
While A[k]<=0 do<br> k:=k-1;
if k>i then
Begin
Swap(A[i],A[k]);
k:=k-1;
WriteLn;
For j:= 1 to N do
Write(A[j]:4)
End
End;
i:=i+1
Until i>k;
End.
Const
N = 2;
Var
A:array[1..N,1..N] of integer;
i,j,m,iMin,jMin,iMin2,jMin2:integer;
Begin
Randomize;
WriteLn('Исходная матрица:');
For i:= 1 to N do
Begin
For j:= 1 to N do
Begin
A[i,j]:=random(21)-10;
Write(A[i,j]:3,' ')
End;
WriteLn;
End;
iMin:=1;
jMin:=1;
For i:= 1 to N do
For j:= 1 to N do
if A[iMin,jMin]>A[i,j] then
Begin
iMin:=i;
jMin:=j;
End;
Swap(A[N,1],A[iMin,jMin]);
For m:= 1 to N-1 do
Begin
iMin2:=1;
jMin2:=1;
For i:= 1 to N do
For j:= 1 to N do
if (A[i,j]<=A[iMin2,jMin2])and(A[i,j]>=A[N-m+1,m])and((i<>N-m+1)or(j<>m)) then
Begin
iMin2:=i;
jMin2:=j;
End;
Swap(A[N-m,m+1],A[iMin2,jMin2]);
End;
WriteLn;
WriteLn('Результирующая матрица:');
For i:= 1 to N do
Begin
For j:= 1 to N do
Write(A[i,j]:3,' ');
WriteLn;
End;
End.