//PascalABC.NET 3.2 сборка 1318
Var
ar1,ar2:array of integer;
n1,n2,i:integer;
procedure GenNotOdd(var ar1,ar2:array of integer;n:integer);
Var
i,j:integer;
begin
i:=1;
j:=0;
setlength(ar1,n div 2);
while i<=n-1 do<br> begin
ar1[j]:=ar2[i];
inc(j);
i+=2;
end;
end;
procedure SwapArr(var ar1,ar2:array of integer;var n1,n2:integer);
Var
buf:array of integer;
i,j,otbuf:integer;
begin
setlength(buf,n2);
for i:=0 to n2-1 do
buf[i]:=ar2[i];
GenNotOdd(ar2,ar1,n1);
GenNotOdd(ar1,buf,n2);
otbuf:=n2;
n2:=n1 div 2;
n1:=otbuf div 2;
end;
procedure ReadArr(var ar:array of integer;var n:integer);
Var
i:integer;
begin
readln(n);
setlength(ar,n);
for i:=0 to n-1 do
readln(ar[i]);
end;
procedure WriteArr(ar:array of integer;n:integer);
Var
i:integer;
begin
for i:=0 to n-1 do
write(ar[i]:4);
writeln;
end;
begin
ReadArr(ar1,n1);
ReadArr(ar2,n2);
SwapArr(ar1,ar2,n1,n2);
WriteArr(ar1,n1);
WriteArr(ar2,n2);
end.
Пример ввода:
2
1 2
7
1 2 3 4 5 6 7
Пример вывода:
2 4 6
2