Const n=10;
var a:array[1..n] of integer;
i,h:integer;
begin
Randomize;
for i:=1 to n do begin
a[i]:=random(51);
write(a[i],' ');
end;
writeln;
for i:=1 to n div 2 do
begin
h:=a[2*i-1]; a[2*i-1]:=a[2*i]; a[2*i]:=h
end;
for i:=1 to n do write(a[i],' ');
writeln;
end.
Пример:
8 7 12 28 22 50 15 36 6 40
7 8 28 12 50 22 36 15 40 6