1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48

#include <iostream>
#include <vector>
using namespace std;
void quickSort(vector<int> vec, int left, int right)
{
int i = left;
int j = right;
int tmp;
int pivot = vec.at((left + right) / 2);
while (i <= j)
{
while (vec.at(i) < pivot)
{
i++;
}
while (vec.at(j) > pivot)
{
j;
}
if (i <= j)
{
tmp = vec.at(i);
vec.at(i) = vec.at(j);
vec.at(j) = tmp;
i++;
j;
}
}
if (left < j)
{
quickSort(vec, left, j);
}
if (i < right)
{
quickSort(vec, i, right);
}
}
int main()
{
vector<int> data = { 1, 12, 5, 26, 7, 14, 3, 7, 2 };
quickSort(data, 0, data.size()  1);
return 0;
}
 