快速排序!

来源:互联网 发布:linux efi boot 编辑:程序博客网 时间:2024/04/30 18:13

void quick_sort(int x[], int low, int high)  
{
 int i=low, j=high;
 int t=x[low];  
 

  while (i<j) 
  {
    while (i<j && x[j]>t) 
     j--; 
 
  x[i]=x[j]; 


    while (i<j && x[i]<=t)
    i++;  
 
  x[j]=x[i]; 

   x[i] = t;    
 
   quick_sort(x,low,i-1); 

   quick_sort(x,i+1,high); 

}

无意中发现这个快速排序的算法,简洁,高效!   初学者适合学习!