主题:关于快排,急!!!
这是TP自带的快排,是从小到大排序的,谁能帮我改成从大到小排的?
const maxn=10000;
type arr:array[1..maxn] of longint;
var a:arr;
i,n:longint;
procedure qsort(var a:arr;lo,hi:longint);
procedure sort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;j:=r;x:=a[(l+r) div 2];
repeat
while a[i]<x do i:=i+1;
while x<a[j] do j:=j-1;
if i<=j
then
begin
y:=a[i];a[i]:=a[j];a[j]:=y;
i:=i+1;j:=j-1;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
sort(lo,hi);
end;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
qsort(a,1,n);
end.
const maxn=10000;
type arr:array[1..maxn] of longint;
var a:arr;
i,n:longint;
procedure qsort(var a:arr;lo,hi:longint);
procedure sort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;j:=r;x:=a[(l+r) div 2];
repeat
while a[i]<x do i:=i+1;
while x<a[j] do j:=j-1;
if i<=j
then
begin
y:=a[i];a[i]:=a[j];a[j]:=y;
i:=i+1;j:=j-1;
end;
until i>j;
if l<j then sort(l,j);
if i<r then sort(i,r);
end;
begin
sort(lo,hi);
end;
begin
readln(n);
for i:=1 to n do
readln(a[i]);
qsort(a,1,n);
end.