#include<iostream>
#include<unordered_map>
#include<vector>
using namespace std;
int partition(vector<int>& arr, int low, int high) {
int x = arr[high];
int i = low - 1; //spliter
int j = low; //checker
while (j < high) {
if (arr[j] < x) {
i++;
swap(arr[i], arr[j]);
}
j++;
}
i++;
swap(arr[i], arr[high]);
return i;
}
void quicksort(vector<int>& arr, int low, int high) {
if (low >= high)
return;
int xpos = partition(arr, low, high);
quicksort(arr, low, xpos - 1);
quicksort(arr, xpos + 1, high);
}
void main() {
vector<int> nums = { 38, 27, 43, 3, 9, 82, 10 };
quicksort(nums, 0, nums.size() - 1);
for (int x : nums) cout << x << "\t";
}