Const n=10;
var a:array[1..n] of integer;
i,sum:integer;
begin
Randomize;
for i:=1 to n do
begin
a[i]:=random(11)-5;
write(a[i],' ');
end;
writeln;
sum:=0;
for i:=1 to n do
if a[i]>0 then sum:=sum+a[i];
writeln('sum=',sum);
end.
Пример:
5 -1 -4 4 -5 0 -5 4 5 -3
sum=18