快速排序

void QuickSort(int array[], int start, int last)
{
    int i = start;
    int j = last;
    int temp = array[i];
    if (i < j)
    {
        while (i < j)      //
        {
            //
            while (i < j &&  array[j]>=temp )   //从右向左,找到一个小于temp的数截止
                j--;
            if (i < j)
            {
                array[i] = array[j]; //将temp本来的位置等于一个小于他的数
                i++;
            }

            while (i < j && temp > array[i])
                i++;
            if (i < j)
            {
                array[j] = array[i];
                j--;
            }
                        
        }
        //把基准数放到i位置
        array[i] = temp;
        //递归方法
        QuickSort(array, start, i - 1);
        QuickSort(array, i + 1, last);
    }
}
原文地址:https://www.cnblogs.com/hozhangel/p/12596811.html