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.
Answers & Comments
Verified answer
//Pascal ABC.NET 3.1 сборка 1219Const
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.