split(int a[],int low,int high,int &i)
{
int j,temp,t;
i=low;
j=high;
t=a[i];
while(i<j)
{
while(i<j && a[i]<=t)
i++;
if(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
j--;
}
while(i<j &&a[j]>=t)
j--;
if(i<j)
{
temp=a[i];
a[i]=a[j];
a[j]=temp;
i++;
}
}
if(i!=low)
{
for(int k=low+1;k<=i;k++)
a[k-1]=a[k];
}
a[i-1]=t;
}
sort(int a[],int low,int high)
{
int i;
if(low<high)
{
split(a,low,high,i);
sort(a,low,i-2);
sort(a,i,high);
}
}
void qsort(int a[],int n)
{
sort(a,0,n-1);
}
void main()
{
int a[]={2,6,4,9,0,3};
for(int i=0;i<6;i++)
cout<<a[i]<<" ";
cout<<endl;
qsort(a,6);
for(i=0;i<6;i++)
cout<<a[i]<<" ";
cout<<endl;
}