第20762题 单选题
C++从小到大排序的快速排序partition函数空缺代码选择

给定以下C++快速排序相关代码,选择partition函数横线处应填入的最佳代码:

int partition(vector<int>& arr, int low, int high) {
  int pivot = arr[high]; // 基准值 
  int i = low - 1; 

  for (int j = low; j < high; j++) {
    ________________________________ // 在此处填入代码
  }
  swap(arr[i + 1], arr[high]);
  return i + 1;
}

// 快速排序
void quickSort(vector<int>& arr, int low, int high) {
  if (low < high) {
    int pi = partition(arr, low, high);
    quickSort(arr, low, pi - 1);
    quickSort(arr, pi + 1, high);
  }
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析