#include<stdio.h>
//以最小为开头,一个一个型
/*int sort(int A[],int low,int high){
    int temp;
    int mean=(low+high)/2;
    if((A[mean]-A[low])*(A[mean]-A[high])<=0){temp=A[low];A[low]=A[mean];A[mean]=temp;}
    else if((A[low]-A[mean])*(A[low]-A[high])<=0){}
    else{temp=A[high];A[high]=A[low];A[low]=temp;}
    temp=A[low];
    while(low<high){
        while(low<high && A[high]>=temp){high--;}
        A[low]=A[high];
        while(low<high &&  A[low]<temp){low++;}
        A[high]=A[low];
    }A[low]=temp;return low;
}*/

//交换型,从小偷开始
int sort(int A[],int low,int high){
    int temp;
    int mean=(low+high)/2;
    if((A[mean]-A[low])*(A[mean]-A[high])<=0){temp=A[low];A[low]=A[mean];A[mean]=temp;}
    else if((A[low]-A[mean])*(A[low]-A[high])<=0){}
    else{temp=A[high];A[high]=A[low];A[low]=temp;}
    mean=low;temp=A[low];
    while(low<high){
        while(low<high && A[high]>=temp){high--;}
        while(low<high &&  A[low]<=temp){low++;}
        if(low!=high){int a=A[low];A[low]=A[high];A[high]=a;}
    }A[mean]=A[low];A[low]=temp;return low;
}



void SortList(int A[],int low,int high){
    if(low<high){
        int temp=sort(A,low,high);
        SortList(A,low,temp-1);
        SortList(A,temp+1,high);
    }
}
int main(){
    int A[10];
    for(int i=10;i>0;i--){A[10-i]=i;}
    for(int i=0;i<10;i++){printf("%d  ",A[i]);}
    printf("\n");
    SortList(A,0,9);
    for(int i=0;i<10;i++){printf("%d  ",A[i]);}
    printf("\n");
    return 0;
}