Переведите кусок кода с Pascal на C++ (Паскаль и Си++):
read(a);
if odd(i) then a1 += a
else a2 += a;

Вот весь код:
var
n, m, a, a1, a2, b, b1, b2, rez1, rez2: int64;
i: integer;

Begin
readln(n, m);
a1 := 0; a2 := 0;
for i := 1 to n do
begin
read(a);
if odd(i) then a1 += a
else a2 += a;
end;
readln;
for i := 1 to m do
begin
read(b);
if odd(i) then b1 += b
else b2 += b;
end;
readln;
rez1 := a1 * b1 + a2 * b2;
rez2 := a1 * b2 + a2 * b1;
writeln(rez1, ' ', rez2);
End.
Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Copyright © 2024 SCHOLAR.TIPS - All rights reserved.