#include <iostream>
#include <vector>

using namespace std;

void quick_sort(vector<int>& arr, int left, int right) {
    if (left >= right ) {
        return;
    }
    if (left < 0 || right >= arr.size()) {
        return;
    }
    int i, j;
    i = left;
    j = right;
    while(i < j) {
        while (arr[j] >= arr[left] && i < j) {
            j--;
        }
        while (arr[i] <= arr[left] && i < j) {
            i++;
        }
        if (i < j) {
            arr[i]^=arr[j];
            arr[j]^=arr[i];
            arr[i]^=arr[j];
        }
    }
    arr[left]^=arr[i];
    arr[i]^=arr[left];
    arr[left]^=arr[i];
    quick_sort(arr, left, i - 1);
    quick_sort(arr, i + 1, right);
}

int main() {
    vector<int> arr = {6, 1, 2, 7, 9, 3, 4, 5, 10, 8};
    quick_sort(arr, 0, arr.size()-1);
    for (int i = 0; i < arr.size(); i++) {
        cout << arr[i] << " ";
    }
    cout << endl;
    return 0;
}