voidQsort (int*a,intLintR) {
if(L>=R)return;
intP=l,q=r;
intVAL=A[L];
while(P!=Q) {
while(P<q&&a[q]>val) q--;
if(P<Q) a[p++]=a[q];
while(P<q&&a[p]<=val) p++;
if(P<Q) a[q--]=a[p];
}
A[p]=val;
Qsort (a,l,p-1);
Qsort (a,p+1, R);
}
voidMergeSort (int*a,int*t,intLintR) {
if(L>=R)return;
intMid= (l+r) >>1;
MergeSort (A,t,l,mid);
MergeSort (a,t,mid+1, R);
intP=l,q=mid+1, I=l;
while(P<=MID&&Q<=R) {
t[i++]=a[p]<=a[q]?a[p++]:a[q++];
}
while(P<=mid) t[i++]=a[p];
while(q<=r) t[i++]=a[q];
for(inti=l;i<=r;i++) A[i]=t[i];
}
voidHeapadjust (int*a,intPosintSZ) {
if(pos>sz/2)return;
intlchild=pos*2, rchild=pos*2+1;
intMin=pos;
if(Lchild<=sz&&a[lchild]>a[min]) {
Min=lchild;
}
if(Rchild<=sz&&a[rchild]>a[min]) {
Min=rchild;
}
if(Min!=pos) {
Swap (a[pos],a[min]);
Heapadjust (A,MIN,SZ);
}
}
voidBuildheap (int*a,intSZ) {
for(inti=sz/2; i>=1; i--) {
Heapadjust (A,I,SZ);
}
}
voidHeapsort (int*a,intSZ) {
Buildheap (A,SZ);
for(inti=sz;i>=1; i--) {
Swap (a[1],a[i]);
Heapadjust (A,1, I-1);
}
}
Three kinds of simple sort write down on the sticker