第19989题 单选题
将数组奇数放前半部分、偶数放后半部分的C++代码第9行横线处应填入的语句是?
#include <iostream>
using namespace std;

int main() {
 int arr[] = {1, 2, 3, 4, 5};
 int left = 0, right = 4;
 while (left < right) {
  while (arr[left] % 2 == 1 && left < right) left++;
  ————————————————————————————————————————————————
  if (left < right) {
   swap(arr[left], arr[right]);
  }
 }
 for (int i = 0; i < 5; i++) {
  cout << arr[i] << " ";
 }
 return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析