G. [GESP]L5-202309-Q1882-S
[GESP]L5-202309-Q1882-S
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
根据下面 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;
}
{{ select(1) }}
compare和isOdd(lstA[i])compare(x1,y1)和isOddcompare和isOddcompare(x1,y1)和isOdd(lstA[i])
GESP 2023.09 C++ 五级 全真模拟赛
- 状态
- 已结束
- 规则
- OI
- 题目
- 27
- 开始于
- 2026-11-20 13:29
- 结束于
- 2026-11-25 13:29
- 持续时间
- 2 小时
- 主持人
- 参赛人数
- 0