第20848题 单选题
如下C++代码中两处横线应分别填入哪组内容

根据代码注释,补全两处空缺的代码:

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool isOdd(int N) {
    return N % 2 == 1;
}
bool compare(int a, int b) {
    if (a % 2 == 0 && b % 2 == 1)
        return true;
    return false;
}
int main() {
    vector<int> lstA; // lstA是一个整型向量
    for (int i = 1; i < 100; i++)
        lstA.push_back(i);
    // 对lstA成员按比较函数执行结果排序
    sort(lstA.begin(), lstA.end(), ____); // 此处填写代码1
    vector<int> lstB;
    for (int i = 0; i < lstA.size(); i++) // lstB成员全为奇数
        if (____________) // 此处填写代码2
            lstB.push_back(lstA[i]);
    cout << "lstA: ";
    for (int i = 0; i < lstA.size(); i++)
        cout << lstA[i] << " ";
    cout << endl;
    cout << "lstB: ";
    for (int i = 0; i < lstB.size(); i++)
        cout << lstB[i] << " ";
    cout << endl;
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析