Var ar:array[1..n] of integer; i,j:integer; begin randomize; writeln('Array:'); for i:=1 to n do begin ar[i]:=random(-10,10); write(ar[i]:4); end; for i:=1 to n-1 do for j:=i+1 to n do if abs(ar[i])>abs(ar[j]) then swap(ar[i],ar[j]); writeln; writeln('Final array:'); for i:=1 to n do write(ar[i]:4); end.
Const
n=10;
Var
ar:array[1..n] of integer;
i,j:integer;
begin
randomize;
writeln('Array:');
for i:=1 to n do
begin
ar[i]:=random(-10,10);
write(ar[i]:4);
end;
for i:=1 to n-1 do
for j:=i+1 to n do
if abs(ar[i])>abs(ar[j]) then swap(ar[i],ar[j]);
writeln;
writeln('Final array:');
for i:=1 to n do
write(ar[i]:4);
end.