//用记事本写的,可能有些bug
//快速排序
Procedure qsort(l,r:longint);
var i,j,x,y:longint;
begin
i:=l;j:=r;x:=a[random(r-l)+l];//随机化即可
Repeat
while a<x do inc(i);
while a[j]>x do dec(j);
if i<=j then
begin
y:=a;
a:=a[j];
a[j]:=y;
inc(i);
dec(j);
end;
until i>j;
if i<r then qsort(i,r);
if j>l then qsort(l,j);
end;
begin
S:=edit1.text;
top:=0;now:='';
for i:=1 to length(s) do
if s[i]=',' then begin inc(top);val(now,a[top],code);now:='';end else now:=now+s[i];
//如果最后还有一个数,将这个数纳入栈
if now<>'' then begin inc(top);val(now,a[top],code);end;
//排序
qsort(1,top);
s:='';
for i:=1 to top do
begin
str(a[i],now);
s:=s+now+',';
end;
//除去最后一个','
s:=copy(s,1,length(s)-1);
edit2.text:=s;
end;
追问a是哪来的啊?
追答a是一个整型数组