0%

快排

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void mysort(vector<int>& nums, int l, int r){
if(l>=r) return;
int tl = l;
int tr = r;

int flag = nums[l];
while(l<r){

while(l<r&&flag<=nums[r]){
r--;
}
nums[l] = nums[r];
while(l<r&&nums[l]<=flag){
l ++;
}
nums[r] = nums[l];
}
nums[l] = flag;

mysort(nums, tl, l-1);
mysort(nums, l+1, tr);
}

Welcome to my other publishing channels