测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A18413. 下面代码段实现了快速排序的划分操作(以首元素为基准),横线处代码应填入( )。int partition(vector<int>& arr, int low, int high) { int pivot = arr[low]; int i = low, j = high; while (i < j) { while (i < j && arr[j] >= pivot) j--; while (i…

单选题 困难

题目描述

下面代码段实现了快速排序的划分操作(以首元素为基准),横线处代码应填入(    )。

int partition(vector<int>& arr, int low, int high) {
	int pivot = arr[low];
	int i = low, j = high;
	while (i < j) {
		while (i < j && arr[j] >= pivot) j--;
		while (i < j && arr[i] <= pivot) i++;
		if (i < j) swap(arr[i], arr[j]);
	}
	________________;
	// 在此处填入代码
	return i;
}

选项(单选)

上一题 下一题