Example #1
0
int main(){
	int a[11] = {0, 9, 8, 6, 4, 1, 10, 19, 16, 5, 7};
	display(a, 11);
	quick_Sort(a, 0, 11);
	display(a, 11);
return 0;
}
void quick_Sort(int a[],int left,int right)
{
   int i,j,temp;
   i=left;
   j=right;
   temp=a[left];
   if(left>right)
      return;
   while(i!=j)/*find the final position*/
   {
      while(a[j]>=temp && j>i)
         j--;
      if(j>i)
         a[i++]=a[j];
       while(a[i]<=temp && j>i)
          i++;
       if(j>i)
          a[j--]=a[i];

   }
   a[i]=temp;
   quick_Sort(a,left,i-1);/*recursion left*/
   quick_Sort(a,i+1,right);/*recursion right*/
}