program p_1;
const
n=10;
var
s:array[1..n] of integer;
m:integer;
procedure sort(lx,rx:integer);
var
i,j,t:integer;
begin
i:=lx; j:=rx; t:=s[i];
repeat
while (s[j]>t) and (i<j) do j:=j-1;
if (i<j) then
begin
s[i]:=s[j];
i:=i+1;
while (s[i]<t) and (i<j) do i:=i+1;
if (i<j) then
begin
s[j]:=s[i];
j:=j-1;
end;
end;
until i=j;
s[i]:=t; i:=i+1; j:=j-1;
if (lx<j) then sort(lx,j);
if (i<rx) then sort(i,rx);
end;
begin
write('input data');
for m:=1 to n do
read(s[m]);
sort(1,n);
for m:=1 to n do
write(s[m],' ');
end.
posted on 2005-08-18 22:23
李青 阅读(1012)
评论(4) 编辑 收藏 引用