#include <iostream>
using namespace std;
int partition(int a[], int low, int high)
{
int pivot = high;
int first_high=low;
for (int i = low; i < high; ++i)
{
if (a[i] < a[pivot])
{
int tem = a[i];
a[i] = a[first_high];
a[first_high] = tem;
first_high++;
}
}
int tem2 = a[pivot];
a[pivot] = a[first_high];
a[first_high] = tem2;
return first_high;
}
void quickSort(int a[], int low, int high)
{
int q;
if (low < high)
{
q = partition(a, low, high);
quickSort(a, low, q - 1);
quickSort(a, q + 1, high);
}
}
int main()
{
int a[] = { 1, 23, 34, -5411, 111, -3333 };
//cout << partition(a, 0, 5) << endl;
quickSort(a, 0, 5);
for (int i = 0; i < 6; ++i)
{
cout << a[i] << " ";
}
system("pause");
}