#include <iostream>
#include <vector>
using namespace std;
template<class Iter> inline
void quickSort(const Iter &begin,const Iter &end) {
if (begin >= end-1) return;
auto i = begin;
auto j = end-1;
auto base = *begin;
while (i < j) {
while (*j >= base && j > i) {
j--;
}
while (*i <= base &&j > i) {
i++;
}
if (i < j) {
auto temp = *j;
*j = *i;
*i = temp;
}
}
*begin = *i;
*i = base;
quickSort(begin, i);
quickSort(i + 1, end);
}
int main() {
vector<int> arr{5,6,77,88,4,7,55,2,23,67};
quickSort(arr.begin(), arr.end());
for (auto i = arr.begin(); i != arr.end(); i++)
cout << *i << " ";
cout << endl;
system("pause");
return 0;
}
只能实现连续空间内的排序