|
program kuaisu(input,output); const n=10; var s:array[1..10] of integer; k,l,m,o:integer;
procedure qsort(lx,rx:integer); var I,j,t:integer; Begin I:=lx;j:=rx;t:=s[I]; Repeat While (s[j]>t) and (j>I) do Begin k:=k+1; j:=j-1 end; if I<j then begin s[I]:=s[j];I:=I+1;l:=l+1; while (s[I]<t) and (I<j) do begin
I:=I+1 End; 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; o:=o+1; writeln('第',o:3,'次排序的结果:'); for m:=1 to 10 do write(s[m]:5); writeln; If lx<j then qsort(lx,j); If I<rx then qsort(I,rx) End;{过程qsort结束}
Begin Writeln('input 10 integer num:'); For m:=1 to n do read(s[m]); K:=0;l:=1; o:=0; Qsort(l,n); Writeln('shu chu jie guo:'); For m:=1 to n do write(s[m]:4) ; End.
|