#include<iostream>
using namespace std;
int part(int a[],int low,int high)
{
int pivot;
int i,lastsmall=low;
int t=a[low]; a[low]=a[(low+high)/2]; a[(low+high)/2]=t;
pivot=a[low];
for(i=low+1;i<=high;i++)
if(a[i]<pivot){
lastsmall=lastsmall+1;
t=a[i]; a[i]=a[lastsmall]; a[lastsmall]=t;
}
t=a[low]; a[low]=a[lastsmall]; a[lastsmall]=t;
return lastsmall;
}
void quicks(int a[],int low,int high)
{
if(low==high) return ;
int pivot_position;
if(low<high)
{
pivot_position=part(a,low,high);
quicks(a,low,pivot_position);
quicks(a,pivot_position+1,high);
}
}
int main(){
int a[]={1,3,2,6,5,7,9,4,0,8,89,76,209,47,67};
for(int j=0;j<15;j++)
cout<<a[j]<<" ";
cout<<endl<<"after the quicksort :"<<endl;
quicks(a,0,14);
for(int i=0;i<15;i++) cout<<a[i]<<" ";
return 0;
}