来自本人百度空间 2009-08-20 16:42
program qsort(input,output);
var
top,k:longint;
a:array[1..10000] of longint;
procedure qsort(lx,rx:integer);
var i,j,t,c:longint;
begin
i:=lx; j:=rx; t:=a[i];
repeat
while (a[j]>t) and (i<j) do dec(j);
if i<j then begin
a[i]:=a[j]; inc(i);
while (a[i]<t) and (i<j) do inc(i);
if i<j then begin
a[j]:=a[i]; dec(j);
end;
end;
until j<=i;
a[i]:=t;
dec(j); inc(i);
if j>lx then qsort(lx,j);
if i<rx then qsort(i,rx);
end;{qsort}
begin
assign(input,'qsort.in');
reset(input);
assign(output,'qsort.out');
rewrite(output);
while not(eof) do begin
inc(top);
read(a[top]);
end;
close(input);
qsort(1,top);
for k:=1 to top-1 do write(a[k],' ');
writeln(a[top]);
close(output);
end.