void qSort(int _left, int _right, vector<int>& vec)
{
if (_left >= _right)
return;
int left = _left, right = _right;
int base = vec[left];
while (left < right)
{
while (left < right && vec[right] > base) --right;
vec[left] = vec[right];
while (left < right && vec[left] <= base) ++left;
vec[right] = vec[left];
}
vec[left] = base;
qSort(_left, left - 1, vec);
qSort(left + 1, _right, vec);
}
快速排序 c++
最新推荐文章于 2024-08-22 15:48:46 发布