快排程序-PASCAL 快速排序程序

PASCAL 快速排序程序

1、 PASCAL快速排序程序

1、 PASCAL快速排序程序

学着写楼下的两个快速排序。新手要好好学习,非递归快速排序怎么可能要。

procerekp(l,r:longint);i,j,x,t:longint;快速排序算法c语言。

begin

i:=l;j :=r;x:=a[(l+r)div2];快速排序c语言代码。

whilea[i]

whilex
ifi<=jthenbegint:=a[i];a[i]:=a[j];a[j]:=t;inc(i);dec(j);end;

untili>j;

ifi

ifl

end;

开始快排程序}

readln(n);fori:=1tondoread(a[i] );kp(1,n);快速排序原理图解。

fori:=1tondowrite(a[i],'');快速排序C语言。

end.n,i:longint;

a:array[1、.]oflongint;

procereqsort(l,r:longint);

vari,j,mid ,t:longint;

i:=l;j:=r;mid:=a[(l+ r)div2];

whilea[i]

whilea[j]>middodec(j);

ifi<=jthen

begin

t :=a[i];

a[i]:=a[j] ;

a[j]:=t;

inc(i);dec(j);

end;

untili>j;

ifl

ifi

end;

readln(n);
fori:=1tondo

qsort(1,n);

fori:=1tondo

writeln(a[i]);

end.

PASCAL 快速排序程序www.hdianbao.com

您可能还会对下面的文章感兴趣: