var
A: array [1..11] of Real;
i, j, aj, ai: Integer;
amax, atmp, P: Real;
begin
Randomize;
WriteLn ('Исходный массив:');
for i := Low (A) to High (A) - 1 do begin
A [i] := Random * 100;
Write (A [i]:5:2, ' ');
end;
A [i] := Round (A [i]);
amax := A [i];
aj := i;
for j := i to High (A) do begin
if A [j] > amax then begin
amax := A [j];
aj := j;
if i <> aj then begin
atmp := A [i];
A [i] := A [aj];
A [aj] := atmp;
WriteLn;
WriteLn ('Полученный массив:');
Write ('Введите число Р: ');
Read (P);
ai := High (A);
if P > A [i] then begin
ai := i;
Break;
for i := High (A) downto ai + 1 do
A [i] := A [i - 1];
A [ai] := P;
WriteLn ('Массив после вставки:');
for i := Low (A) to High (A) do begin
end.
var
A: array [1..11] of Real;
i, j, aj, ai: Integer;
amax, atmp, P: Real;
begin
Randomize;
WriteLn ('Исходный массив:');
for i := Low (A) to High (A) - 1 do begin
A [i] := Random * 100;
Write (A [i]:5:2, ' ');
end;
for i := Low (A) to High (A) - 1 do begin
A [i] := Round (A [i]);
end;
for i := Low (A) to High (A) - 1 do begin
amax := A [i];
aj := i;
for j := i to High (A) do begin
if A [j] > amax then begin
amax := A [j];
aj := j;
end;
end;
if i <> aj then begin
atmp := A [i];
A [i] := A [aj];
A [aj] := atmp;
end;
end;
WriteLn;
WriteLn ('Полученный массив:');
for i := Low (A) to High (A) - 1 do begin
Write (A [i]:5:2, ' ');
end;
WriteLn;
Write ('Введите число Р: ');
Read (P);
ai := High (A);
for i := Low (A) to High (A) - 1 do begin
if P > A [i] then begin
ai := i;
Break;
end;
end;
for i := High (A) downto ai + 1 do
A [i] := A [i - 1];
A [ai] := P;
WriteLn ('Массив после вставки:');
for i := Low (A) to High (A) do begin
Write (A [i]:5:2, ' ');
end;
end.