var
A: array [1..10] of integer;
i : integer;
temp : integer;
begin
Randomize;
for i := 1 to 10 do
A[i] := random(30);
Write(A[i], ' ');
end;
Writeln;
i := 1;
while i < 10 do
temp := A[i];
A[i] := A[i + 1];
A[i + 1] := temp;
inc(i, 2);
Writeln('Новый массив: ');
for i := 1 to 10 do Write(A[i], ' ');
end.
Объяснение:
var
A: array [1..10] of integer;
i : integer;
temp : integer;
begin
Randomize;
for i := 1 to 10 do
begin
A[i] := random(30);
Write(A[i], ' ');
end;
Writeln;
i := 1;
while i < 10 do
begin
temp := A[i];
A[i] := A[i + 1];
A[i + 1] := temp;
inc(i, 2);
end;
Writeln('Новый массив: ');
for i := 1 to 10 do Write(A[i], ' ');
end.
Объяснение: