void qsort(int v[], int left, int right)
{
    int i, last;
    void swap(int v[], int i, int j);
    if (left >= right)
        return;
    swap(v, left, (left + right) / 2); /*将划分元素移到*/
    last = left;                       /*v[0]处*/
    for (i = left + 1; i <= right; i++)
    if (v[i] < v[left])
        swap(v, ++last, i);
    swap(v, left, last);                /*恢复划分子集的元素*/
    qsort(v, left, last - 1);
    qsort(v, last - 1, right);
    
}
void swap(int v[], int i, int j)
{
    int temp;
    temp = v[i];
    v[i] = v[j];
    v[j] = temp;
}

 

 

posted on 2013-11-04 11:18  欧小弟  阅读(185)  评论(0编辑  收藏  举报