
Зиновий
6 год назад
Дан одномерный массив, получить удвоенную сумму всех положительных членов массива и найти сумму чисел, которые не четные и отрицательные

ОТВЕТЫ

Колемин
Jul 9, 2019
Program zadacha;vara: array[1..1000] of integer;i,n,sum_pol,sum_otr: integer;beginwriteln(vvedite kol-vo elementov massiva);readln(n);for i:=1 to n do begina[i]:=random(1000)-500;write(a[i]:6);end;
sum_pol:=0;sum_otr:=0;for i:=1 to n do beginif a[i]gt;0 then sum_pol:=sum_pol+a[i];end;writeln();writeln(udvoennaya summa polojit. chisel = , sum_pol*2);
for i:=1 to n do beginif (a[i]lt;0) and (i mod 2 lt;gt; 0) then sum_otr:=sum_otr+a[i];end;
writeln(summa otricat. i nechetn. chisel = , sum_otr);end.
sum_pol:=0;sum_otr:=0;for i:=1 to n do beginif a[i]gt;0 then sum_pol:=sum_pol+a[i];end;writeln();writeln(udvoennaya summa polojit. chisel = , sum_pol*2);
for i:=1 to n do beginif (a[i]lt;0) and (i mod 2 lt;gt; 0) then sum_otr:=sum_otr+a[i];end;
writeln(summa otricat. i nechetn. chisel = , sum_otr);end.
168