QuickSort(vector <int> &a, int left,int right)
{
if(left<right)
{
int key=a[left];
int low=left;
int high=right;
while(low<high)
{
while(low<high&&a[high]>key)
{
high--;
}
a[low]=a[high];
while(low<high&&a[low]<key)
{
low++;
}
a[high]=a[low];
}
a[low]=key;
QuickSort(a,left,low-1);
QuickSort(a,low+1,right);
}
}
{
if(left<right)
{
int key=a[left];
int low=left;
int high=right;
while(low<high)
{
while(low<high&&a[high]>key)
{
high--;
}
a[low]=a[high];
while(low<high&&a[low]<key)
{
low++;
}
a[high]=a[low];
}
a[low]=key;
QuickSort(a,left,low-1);
QuickSort(a,low+1,right);
}
}