Загрузка данных


#include <iostream>
using namespace std;

void quickSort(int a[], int l, int r) {
    int i = l, j = r;
    int x = a[(l + r) / 2];

    while (i <= j) {
        while (a[i] < x) i++;
        while (a[j] > x) j--;

        if (i <= j) {
            swap(a[i], a[j]);
            i++;
            j--;
        }
    }

    if (l < j) quickSort(a, l, j);
    if (i < r) quickSort(a, i, r);
}

int main() {
    int a[] = {5, 2, 8, 1, 3};
    int n = 5;

    quickSort(a, 0, n - 1);

    for (int i = 0; i < n; i++)
        cout << a[i] << " ";
}