var a,i,s,k:integer;
begin
s:=0; k:=0;
for i:=1 to 16 do
a:=random(36)-16;
write(a,' ');
if a<0 then
begin k:=k+1; s:=s+a; end;
end;
writeln;
if k=0 then writeln('Нет отрицательных')
else writeln('k = ',k,' s = ',s,' sr = ',s/k:5:3);
end.
Пример:
-8 17 -1 -8 11 8 -5 7 8 -4 4 5 10 -16 12 4
k = 6 s = -42 sr = -7.000
var a,i,s,k:integer;
begin
s:=0; k:=0;
for i:=1 to 16 do
begin
a:=random(36)-16;
write(a,' ');
if a<0 then
begin k:=k+1; s:=s+a; end;
end;
writeln;
if k=0 then writeln('Нет отрицательных')
else writeln('k = ',k,' s = ',s,' sr = ',s/k:5:3);
end.
Пример:
-8 17 -1 -8 11 8 -5 7 8 -4 4 5 10 -16 12 4
k = 6 s = -42 sr = -7.000