var arr: array[1..10] of integer; i, sumEven, sumOdd: integer;
begin sumEven := 0; sumOdd := 0;
// заполнение массива случайными числами на интервале [-50; 50] Randomize; for i := 1 to 10 do begin arr[i] := Random(101) - 50; writeln('arr[', i, '] = ', arr[i]);
// подсчет суммы четных и нечетных элементов if arr[i] mod 2 = 0 then sumEven := sumEven + arr[i] else sumOdd := sumOdd + arr[i];
end;
writeln; writeln('Sum of even elements: ', sumEven); writeln('Sum of odd elements: ', sumOdd);
if sumEven > sumOdd then writeln('Sum of even elements is greater') else if sumOdd > sumEven then writeln('Sum of odd elements is greater') else writeln('Sums of even and odd elements are equal'); end.
program SumOfEvenAndOddElements;
var
arr: array[1..10] of integer;
i, sumEven, sumOdd: integer;
begin
sumEven := 0;
sumOdd := 0;
// заполнение массива случайными числами на интервале [-50; 50]
// подсчет суммы четных и нечетных элементовRandomize;
for i := 1 to 10 do
begin
arr[i] := Random(101) - 50;
writeln('arr[', i, '] = ', arr[i]);
if arr[i] mod 2 = 0 then
sumEven := sumEven + arr[i]
else
sumOdd := sumOdd + arr[i];
end;
writeln;
writeln('Sum of even elements: ', sumEven);
writeln('Sum of odd elements: ', sumOdd);
if sumEven > sumOdd then
writeln('Sum of even elements is greater')
else if sumOdd > sumEven then
writeln('Sum of odd elements is greater')
else
writeln('Sums of even and odd elements are equal');
end.