Var
mas: array[1..9] of integer;
max, min, i, j, k, n: integer;
begin
writeln('Массив до перестановки');
for i := 1 to 9 do
begin
mas[i] := random(11) - random(11);
write(mas[i], ' ');
end;
writeln;
max := mas[1];
min := mas[1];
k := 1;
j := 1;
for i := 1 to 9 do
begin
if mas[i] > max then
begin
max := mas[i];
j := i;
end;
if mas[i] < min then
begin
min := mas[i];
k := i;
end;
end;
n := mas[j];
mas[j] := min;
mas[k] := n;
writeln('Масств после перестановки');
for i := 1 to 9 do
write(mas[i], ' ');
end.