Дан массив из n элементов. найти сумму отрицательных элементов с четными индексами и отдельно с нечетными. (паскаль) 9 класс

MissVika2007 MissVika2007    2   10.08.2019 13:50    2

Ответы
EgorKuleshov EgorKuleshov  04.10.2020 09:26
Var n,i,s1,s2: integer; a: array [1..32767] of integer;
begin
readln(n);
s1:=0;
s2:=0;
for i:=1 to n do read(a[i]);

for i:=1 to n do begin
if (a[i]<0) and (i mod 2=0) then s1:=s1+a[i]
end;

for i:=1 to n do begin
if (a[i]<0) and (i mod 2<>0) then s2:=s2+a[i]
end;

writeln(s1);
writeln(s2);

end.
ПОКАЗАТЬ ОТВЕТЫ
Другие вопросы по теме Информатика