Var
A:array[1..1000] of integer;
B:array[1..3] of integer;
i,N:integer;
Begin
Write('N = ');ReadLn(N);
For i:= 1 to N do
Begin
Read(A[i]);
if A[i] mod 2 <> 0 then B[1]:=B[1]+A[i];
if A[i] mod 2 = 0 then B[2]:=B[2]+A[i];
End;
WriteLn;
For i:= 1 to N do
Write(A[i],' ');
B[3]:=B[1]+B[2];
WriteLn('B[1] = ',B[1]);
WriteLn('B[2] = ',B[2]);
WriteLn('B[3] = ',B[3]);
End.
или так:
Var
A:array of integer;
B:array[1..3] of integer;
i,N:integer;
Begin
Write('N = ');ReadLn(N);
A:=new integer[N];
For i:= 0 to N-1 do
Begin
Read(A[i]);
if A[i] mod 2 <> 0 then B[1]:=B[1]+A[i];
if A[i] mod 2 = 0 then B[2]:=B[2]+A[i];
End;
WriteLn;
For i:= 0 to N-1 do
Write(A[i],' ');
B[3]:=B[1]+B[2];
WriteLn('B[1] = ',B[1]);
WriteLn('B[2] = ',B[2]);
WriteLn('B[3] = ',B[3]);
End.