非递归写法和递归写法
#include <bits/stdc++.h>
using namespace std;
int RandPartition(vector<int>& nums, int left, int right)
{
int pos = round(rand() * 1.0 / RAND_MAX * (right - left) + left);
std::swap(nums[pos], nums[left]);
int tmp = nums[left];
while (left < right) {
while (left < right && nums[right] >= tmp) --right;
std::swap(nums[right], nums[left]);
while (left < right && nums[left] < tmp) ++left;
std::swap