Program n1; const n=15; var sum,i: integer; a: array[1..n] of integer; begin randomize; sum:=0; writeln('массив: '); for i:=1 to n do begin a[i]:=random(10)-3; 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 sum,i: integer;
a: array[1..n] of integer;
begin
randomize;
sum:=0;
writeln('массив: ');
for i:=1 to n do
begin
a[i]:=random(10)-3;
write(a[i],' ');
if (i mod 2=0) and (a[i]>0) then sum:=sum+a[i];
end;
writeln;
writeln('сумма: ',sum);
end.