Program n1; const n=15; var a:array[1..n] of integer; i,sum:integer; begin randomize; sum:=0; writeln('исходный массив: '); for i:=1 to n do begin a[i]:=random(40)-20; write(a[i],' '); if (i mod 2=0) and (a[i]>0) then sum:=sum+a[i]; end; writeln; writeln('искомая сумма: ',sum); end.
Answers & Comments
Verified answer
Program n1;const n=15;
var a:array[1..n] of integer;
i,sum:integer;
begin
randomize;
sum:=0;
writeln('исходный массив: ');
for i:=1 to n do
begin
a[i]:=random(40)-20;
write(a[i],' ');
if (i mod 2=0) and (a[i]>0)
then sum:=sum+a[i];
end;
writeln;
writeln('искомая сумма: ',sum);
end.