Const n=40;
var a:array[1..n] of integer;
s,k,i:integer;
begin
Randomize;
for i:=1 to n do
begin
a[i]:=random(201)-100;
write(a[i]:5);
end;
writeln;
s:=0; k:=0;
for i:=1 to n do
if a[i]>0 then begin s:=s+a[i]; k:=k+1; end;
writeln('sr = ',s/k);
end.
Пример (для n=10):
-21 -76 -82 74 -86 53 66 96 -92 61
sr = 70