На паскале:
const
n=15;
var
a: array [1..n] of integer;
sum,i:integer;
begin
randomize;
sum:=0;
for i:=1 to n do
a[i]:=random(41)-20;
write(a[i]:4);
if a[i]>0 then
sum:=sum+a[i];
end;
writeln;
write('sum: ',sum);
end.
На паскале:
const
n=15;
var
a: array [1..n] of integer;
sum,i:integer;
begin
randomize;
sum:=0;
for i:=1 to n do
begin
a[i]:=random(41)-20;
write(a[i]:4);
if a[i]>0 then
sum:=sum+a[i];
end;
writeln;
write('sum: ',sum);
end.