Var x,n:integer; sr:real; begin sr:=0; for n=1 to 20 do begin readln(x); sr:=sr+x; end; sr:=sr/n; for n=1 to 20 do if x<0 then begin x:=sr; writeln(x) else writeln(x); end.
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.
x,n:integer;
sr:real;
begin
sr:=0;
for n=1 to 20 do
begin
readln(x);
sr:=sr+x;
end;
sr:=sr/n;
for n=1 to 20 do
if x<0
then begin
x:=sr;
writeln(x)
else writeln(x);
end.
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.
Не самое короткое, зато наглядно =)