Во всех программах у меня будет использоваться процедура swap:
procedure swap(a: ^real; b: ^real);
var
t: real;
begin
t := a^;
a^ := b^;
b^ := t;
end;
swap(x,y) - меняет местами значения x и y.
1.
var
A: array[1..100] of real;
i, j, N: integer;
begin
readln(N);
for i := 1 to N do
read(A[i]);
for j := 1 to (N div 2) - 1 do
for i := 1 to (N div 2) - j do
swap(A[i], A[i + 1]);
for j := 1 to (N div 2) - 1 do
for i := (N div 2) + 1 to N - j do
swap(A[i], A[i + 1]);
for i := 1 to N do
writeln(A[i])
end.
2.
var
A: array[1..100] of real;
i, N: integer;
begin
readln(N);
for i := 1 to N do
read(A[i]);
for i := 1 to N - 1 do
swap(A[i], A[i + 1]);
for i := 1 to N do
writeln(A[i])
end.
3.
var
A: array[1..100] of real;
i, N: integer;
begin
readln(N);
for i := 1 to N do
read(A[i]);
for i := N downto 2 do
swap(A[i], A[i - 1]);
for i := 1 to N do
writeln(A[i])
end.