
2个回答
展开全部
我背的就是这个,特别好用,还好记。
procedure quicksort(l,r:longint);
var
__x,i,j,t :longint;
begin
__x:=a[random(r-l+1)+l];
__i:=l;j:=r;
__repeat
____while a[i]<x do inc(i);
____while a[j]>x do dec(j);
____if i<=j then
______begin
________t:=a[i]; a[i]:=a[j]; a[j]:=t;
________inc(i);dec(j);
______end
__until i>j;
__if l<j then quicksort(l,j);
__if i<r then quicksort(i,r);
end;
procedure quicksort(l,r:longint);
var
__x,i,j,t :longint;
begin
__x:=a[random(r-l+1)+l];
__i:=l;j:=r;
__repeat
____while a[i]<x do inc(i);
____while a[j]>x do dec(j);
____if i<=j then
______begin
________t:=a[i]; a[i]:=a[j]; a[j]:=t;
________inc(i);dec(j);
______end
__until i>j;
__if l<j then quicksort(l,j);
__if i<r then quicksort(i,r);
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询