首页 > 代码库 > QuickSort(快速排序)

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);
}

QuickSort(快速排序)