#include <iostream>
using namespace std;
const int N = 10;
int data[] = {6,1,2,7,9,3,4,5,10,8};
void quickSort(int *data,int low,int high);
int partition(int *data, int low , int high);
void printArray(int *data,int n);
int main()
{
quickSort(data,0,N-1);
printArray(data,N);
return 0;
}
void quickSort(int *data,int low,int high)
{
if(low>=high) return;
int key = partition(data,low,high);
quickSort(data,low,key-1);
quickSort(data,key+1,high);
}
int partition(int *data, int low , int high)
{
int temp = data[low];
while(low<high)
{
while(low<high && data[high]>=temp) --high;
data[low] = data[high];
while(low<high && data[low] <=temp) ++low;
data[high] = data[low];
}
data[low] = temp;
return low;
}
void printArray(int *data,int n)
{
for(int i=0;i<n;++i)
{
cout<<data[i]<<" ";
}
cout<<endl;
}
```