Var A: array [1..20] of integer; B, C: array [1..10] of integer; i, tmp: byte; begin
for i := 1 to 20 do begin A[i] := random(30)+1; write(A[i]:4); tmp := tmp + 1; if i mod 2 <> 0 then C[tmp] := A[i] else begin B[tmp - 1] := A[i]; tmp := tmp - 1; end; end;
writeln; for i := 1 to 10 do write(B[i]:4); writeln; for i := 1 to 10 do write(C[i]:4); end.
// PascalABC.NET 3.3, сборка 1590 от 03.12.2017 // Внимание! Если программа не работает, обновите версию!
begin var a:=ArrRandom(20,-50,50); a.Println; var b:=a.Where((v,i)->i.IsOdd).ToArray; b.Println; var c:=a.Where((v,i)->i.IsEven).ToArray; c.Println end.
A: array [1..20] of integer;
B, C: array [1..10] of integer;
i, tmp: byte;
begin
for i := 1 to 20 do
begin
A[i] := random(30)+1;
write(A[i]:4);
tmp := tmp + 1;
if i mod 2 <> 0 then C[tmp] := A[i]
else
begin
B[tmp - 1] := A[i];
tmp := tmp - 1;
end;
end;
writeln;
for i := 1 to 10 do write(B[i]:4);
writeln;
for i := 1 to 10 do write(C[i]:4);
end.
// Внимание! Если программа не работает, обновите версию!
begin
var a:=ArrRandom(20,-50,50); a.Println;
var b:=a.Where((v,i)->i.IsOdd).ToArray; b.Println;
var c:=a.Where((v,i)->i.IsEven).ToArray; c.Println
end.
Пример
-16 -2 32 -40 31 48 26 -44 -18 -29 -31 -48 -15 -44 -19 16 17 7 3 -50
-2 -40 48 -44 -29 -48 -44 16 7 -50
-16 32 31 26 -18 -31 -15 -19 17 3