Const n=15;
var a:array[1..n] of integer;
i,s,k:integer;
begin
Randomize;
for i:=1 to n do
begin
a[i]:=random(21)-10;
write(a[i]:4);
end;
writeln;
s:=0;k:=0;
for i:=1 to n do
if a[i]<0 then a[i]:=0<br> else if a[i]>0 then begin s:=s+a[i];k:=k+1;end;
for i:=1 to n do write(a[i]:4);
writeln;
writeln('s=',s,' k=',k);
end.
Пример:
-8 -3 10 0 3 1 -10 8 4 -3 9 0 -10 -2 1
0 0 10 0 3 1 0 8 4 0 9 0 0 0 1
s=36 k=7