Var a: array [1..20] of real;
i: integer;
b: real;
begin
for i := 1 to 20 do
begin
a[i] := random(100) - 50;
writeln('[', i, '] => ', a[i]);
end;
writeln('------------');
for i := 1 to 20 do
begin
b := b + a[i];
end;
b := b / 20;
for i := 1 to 20 do
begin
if (a[i] < 0) then a[i] := b;
writeln('[', i, '] => ', a[i]);
end;
end.
Не самое короткое, зато наглядно =)