Дан одномерный массив требуется найти сумму четных положительных элементов массива начиная со второго нулевого элемента до четвертого нулевого элемента-Pascal(Паскаль)

program tt;
const n=10;
var a:array[1..n]of integer;
    i,j,k,s:integer;
begin
for i:=1 to n do
read(a[i]);
k:=0; i:=1; s:=0;
while k<4 do
begin
     if k>=2 then if (not odd(a[i]))and(a[i]>0) then s:=s+a[i];
     if a[i]=0 then inc(k);
     inc(i);
     if i>n then break;
end;
writeln('Сумма=',s);
end.

Leave a Comment

82 − = 76