#include<iostream>
using namespace std;
int partition(int a[], int low, int high)
{
int pivot = a[low];
while (low < high)
{
while (low < high && a[high] >= pivot) high--;
a[low] = a[high];
low++;
while (low < high && a[low] <= pivot) low++;
a[high] = a[low];
high--;
}
a[low] = pivot;
return low;
}
void quicksort(int a[], int low, int high)
{
if (low < high)
{
int pivotpos = partition(a, low, high);
quicksort(a, low, pivotpos - 1);
quicksort(a, pivotpos + 1, high);
}
}
int main()
{
int array[10] = { 3, 6, 2, 4, 9, 34, 13, -6, 44 ,33};
quicksort(array, 0, 9);
for (int i = 0; i < 10; i++)
{
cout << array[i] << "\t";
}
return 0;
}