Const n=10; var a:array[1..n] of integer; min,i:integer; begin Randomize; for i:=1 to n do begin a[i]:=random(9)-4; write(a[i]:3); end; writeln; min:=a[1]; for i:=2 to n do if a[i]<min then min:=a[i]; for i:=1 to n do if a[i]=min then a[i]:=-a[i]; for i:=1 to n do write(a[i]:3); end.
Answers & Comments
Verified answer
Const n=10;var a:array[1..n] of integer;
min,i:integer;
begin
Randomize;
for i:=1 to n do begin
a[i]:=random(9)-4;
write(a[i]:3);
end;
writeln;
min:=a[1];
for i:=2 to n do
if a[i]<min then min:=a[i];
for i:=1 to n do
if a[i]=min then a[i]:=-a[i];
for i:=1 to n do write(a[i]:3);
end.
Пример:
-1 -3 2 -4 -4 0 1 0 -4 1
-1 -3 2 4 4 0 1 0 4 1