/
nixywes
/
study
Обзор
Документация
Войти
/
nixywes
/
study
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
algorithm/KR3/task_6_wb4.cpp
40 строк
826 B
SadCat1233
create repo
27 ноя 2025, 11:28
27 ноя 2025, 11:28
082031e
Код
Авторство
О чём код?
#include <iostream> #include <vector> using namespace std; void quickSort(vector<int>& data, int low, int high) { if (low < high) { int pivot = data[high]; int i = low - 1; for (auto j = low; j < high; j++) { if (data[j] < pivot) { i++; swap(data[j], data[i]); } } swap(data[i + 1], data[high]); i = i + 1; quickSort(data, low, i - 1); quickSort(data, i + 1, high); } } int main() { int length; cin >> length; vector<int> data; for (auto i = 0; i < length; i++) { int temp; cin >> temp; data.push_back(temp); } quickSort(data, 0, length - 1); for (auto num = 0; num < length; num++) { cout << data[num] << " "; } return 0; }