QuickSort(快速排序)

void qsort(int a[],int left,int right){
  if(left>=right)
  {

  return;

  }
  int low,high,key;
  low=left;
  high=right;
  key=a[left];
  while(low<high)

  {
    while(low<high && key<=a[high])
    {

     high--;

    }
    a[low]=a[high];
    while(low<high && key>=a[low])
    {

      low++;
    }

    a[high]=a[low];
  }
  a[low]=key;
  qsort(a,left,low-1);
  qsort(a,low+1,right);
}

posted @ 2016-10-24 23:52  woldcn  阅读(234)  评论(0编辑  收藏  举报