林老师 · 客观题题库 · GESP 七级 · 2025 真题

GESP 七级 · 2025 真题

七级 · 2025 真题 · 客观题 · 每题 2 分
真题
复刻
试卷编号OBJ-810996
题目总数25 题 · 50 分
试卷类型客观题
考生须知:
① 本卷为客观题单卷,合计 25 题 · 50 分,全部为客观题;
② 试卷右上角设有 「提交答卷」「重置考试」 按钮,提交后系统自动判分并显示答题正确情况,请确认全部作答后再行提交;
③ 试卷不显示答案,提交后方可查看每题作答与正确答案的对照;
④ 答卷进度会保留在本地缓存中,刷新或再次打开仍可继续作答;
⑤ 本卷仅供学生练习使用;请勿用于其他用途;题面有问题请联系:i64coder@163.com。

判 分 报 告

0 / 50 分
0
答 对 · 得 0
0
答 错 · 失 0
当前筛选下没有题目

客 观 题

25 QUESTIONS · 2 POINTS EACH
第 1 题 单选 未作答

下列哪个选项是C++中的关键字?

(2 分)
GESP 七级 2025-03 · 单选 第1题 | 知识点 标识符与命名、类与对象
第 2 题 单选 未作答

下面代码输出的是( )

01int main() {
02    int a = 5, b = 2;
03    cout << (a >> b) << endl;
04}

(2 分)
GESP 七级 2025-03 · 单选 第2题 | 知识点 程序阅读与输出推断、移位运算
第 3 题 单选 未作答

以下代码的输出是什么?

01int main() {
02    int a = 10;
03    int *p = &a;
04    int *&q = p;
05    *q = 20;
06    cout << a << endl;
07    return 0;
08}

(2 分)
GESP 七级 2025-03 · 单选 第3题 | 知识点 程序阅读与输出推断、引用、指针
第 4 题 单选 未作答

下面代码输出的是( )

01int main() {
02    int arr[5] = {1, 2, 3, 4, 5};
03    int *p = arr + 2;
04    cout << *p << endl;
05    return 0;
06}

(2 分)
GESP 七级 2025-03 · 单选 第4题 | 知识点 程序阅读与输出推断、指针、一维数组
第 5 题 单选 未作答

下列关于排序的说法,正确的是( )。

(2 分)
GESP 七级 2025-03 · 单选 第5题 | 知识点 排序稳定性、归并排序、快速排序
第 6 题 单选 未作答

下面关于C++类构造和析构函数的说法,错误的是( )。

(2 分)
GESP 七级 2025-03 · 单选 第6题 | 知识点 构造与析构、多态与虚函数
第 7 题 单选 未作答

下列关于树和图的说法,错误的是( )。

(2 分)
GESP 七级 2025-03 · 单选 第7题 | 知识点 图的基本概念、二叉树概念、强连通分量
第 8 题 单选 未作答

2025是个神奇的数字,因为它是由两个数20和25拼接而成,而且2025=(20+25)22025 = (20+25)^2。小杨决定写个程序找找小于NN的正整数中共有多少这样神奇的数字。下面程序横线处应填入的是( )。

01#include <string>
02int count_miracle(int N) {
03    int cnt = 0;
04    for (int n = 1; n * n < N; n++) {
05        int n2 = n * n;
06        std::string s = std::to_string(n2);
07        for (int i = 1; i < s.size(); i++)
08        if (s[i] != '0') {
09            std::string sl = s.substr(0, i);
10            std::string sr = s.substr(i);
11            int nl = std::stoi(sl);
12            int nr = std::stoi(sr);
13            if (____________) // 在此处填入选项
14                cnt++;
15        }
16    }
17    return cnt;
18}

(2 分)
GESP 七级 2025-03 · 单选 第8题 | 知识点 程序补全、枚举、string类
第 9 题 单选 未作答

给定一个无向图,图的节点编号从 0n-1,图的边以邻接表的形式给出。下面的程序使用深度优先搜索(DFS)遍历该图,并输出遍历的节点顺序。横线处应该填入的是( )

01#include <iostream>
02#include <vector>
03#include <stack>
04using namespace std;
05void DFS(int start, vector<vector<int>>& graph, vector<bool>& visited) {
06    stack<int> s;
07    s.push(start);
08    visited[start] = true;
09    while (!s.empty()) {
10        int node = s.top();
11        s.pop();
12        cout << node << " "; // 输出当前节点
13        // 遍历邻接节点
14        for (int neighbor : graph[node]) {
15            if (!visited[neighbor]) {
16                ____________
17                ____________
18            }
19        }
20    }
21}
22int main() {
23    int n, m;
24    cin >> n >> m;
25    vector<vector<int>> graph(n);
26    for (int i = 0; i < m; i++) {
27        int u, v;
28        cin >> u >> v;
29        graph[u].push_back(v);
30        graph[v].push_back(u);
31    }
32    vector<bool> visited(n, false);
33    // 从节点 0 开始DFS遍历
34    DFS(0, graph, visited);
35    return 0;
36}

(2 分)
GESP 七级 2025-03 · 单选 第9题 | 知识点 程序补全、深度优先搜索、栈
第 10 题 单选 未作答

给定一个整数数组 nums,找到其中最长的严格上升子序列的长度。子序列是指从原数组中删除一些元素(或不删除)后,剩余元素保持原有顺序的序列。下面的程序横线处应该填入的是( )

01#include <iostream>
02#include <vector>
03#include <algorithm>
04using namespace std;
05int lengthOfLIS(vector<int>& nums) {
06    int n = nums.size();
07    if (n == 0) return 0;
08    vector<int> dp(n, 1);
09    for (int i = 1; i < n; i++) {
10        for (int j = 0; j < i; j++) {
11            if (nums[i] > nums[j]) {
12                ____________
13            }
14        }
15    }
16    return *max_element(dp.begin(), dp.end());
17}
18int main() {
19    int n;
20    cin >> n;
21    vector<int> nums(n);
22    for (int i = 0; i < n; i++) {
23        cin >> nums[i];
24    }
25    int result = lengthOfLIS(nums);
26    cout << result << endl;
27    return 0;
28}

(2 分)
GESP 七级 2025-03 · 单选 第10题 | 知识点 程序补全、LIS、线性DP
第 11 题 单选 未作答

给定一个整数数组 nums,找到其中最长的严格上升子序列的长度。子序列是指从原数组中删除一些元素(或不删除)后,剩余元素保持原有顺序的序列。该程序的时间复杂度为( )

01#include <iostream>
02#include <vector>
03#include <algorithm>
04using namespace std;
05int lengthOfLIS(vector<int>& nums) {
06    int n = nums.size();
07    if (n == 0) return 0;
08    vector<int> dp(n, 1);
09    for (int i = 1; i < n; i++) {
10        for (int j = 0; j < i; j++) {
11            if (nums[i] > nums[j]) {
12                ____________
13            }
14        }
15    }
16    return *max_element(dp.begin(), dp.end());
17}
18int main() {
19    int n;
20    cin >> n;
21    vector<int> nums(n);
22    for (int i = 0; i < n; i++) {
23        cin >> nums[i];
24    }
25    int result = lengthOfLIS(nums);
26    cout << result << endl;
27    return 0;
28}

(2 分)
GESP 七级 2025-03 · 单选 第11题 | 知识点 时间复杂度、LIS、程序阅读与输出推断
第 12 题 单选 未作答

给定两个无向图
G1G_1G2G_2,判断它们是否同构。图的同构是指两个图的节点可以通过某种重新编号的方式完全匹配,且边的连接关系一致。
为了简化问题,假设图的节点编号从 0n-1,并且图的边以邻接表的形式给出。下面程序中横线处应该给出的是( )

01#include <iostream>
02#include <vector>
03#include <map>
04#include <algorithm>
05using namespace std;
06string graphHash(vector<vector<int>>& graph) {
07    vector<string> nodeHashes(graph.size());
08    for (int i = 0; i < graph.size(); i++) {
09        vector<int> neighbors = graph[i];
10        sort(neighbors.begin(), neighbors.end());
11        string hash;
12        for (int neighbor : neighbors) {
13            ____________
14        }
15        nodeHashes[i] = hash;
16    }
17    sort(nodeHashes.begin(), nodeHashes.end());
18    string finalHash;
19    for (string h : nodeHashes) {
20        finalHash += h + ";";
21    }
22    return finalHash;
23}
24int main() {
25    int n;
26    cin >> n;
27    vector<vector<int>> G1(n);
28    for (int i = 0; i < n; i++) {
29        int k;
30        while (cin >> k) {
31            G1[i].push_back(k);
32            if (cin.get() == '\n') break;
33        }
34    }
35    vector<vector<int>> G2(n);
36    for (int i = 0; i < n; i++) {
37        int k;
38        while (cin >> k) {
39            G2[i].push_back(k);
40            if (cin.get() == '\n') break;
41        }
42    }
43    string hash1 = graphHash(G1);
44    string hash2 = graphHash(G2);
45    if (hash1 == hash2) {
46        cout << "YES" << endl;
47    } else {
48        cout << "NO" << endl;
49    }
50    return 0;
51}

(2 分)
GESP 七级 2025-03 · 单选 第12题 | 知识点 程序补全、哈希表、邻接表
第 13 题 单选 未作答

给定一个 m×nm \times n 的二维网格 grid,每个格子中有一个非负整数。请找出一条从左上角 (0,0)(0,0) 到右下角 (m1,n1)(m-1,n-1) 的路径,使得路径上的数字总和最小。每次只能向右或向下移动。横线处应该填入的是( )

01#include <iostream>
02#include <vector>
03#include <algorithm>
04using namespace std;
05int minPathSum(vector<vector<int>>& grid) {
06    int m = grid.size();
07    int n = grid[0].size();
08    vector<vector<int>> dp(m, vector<int>(n, 0));
09    dp[0][0] = grid[0][0];
10    for (int j = 1; j < n; j++) {
11        dp[0][j] = dp[0][j - 1] + grid[0][j];
12    }
13    for (int i = 1; i < m; i++) {
14        dp[i][0] = dp[i - 1][0] + grid[i][0];
15    }
16    for (int i = 1; i < m; i++) {
17        for (int j = 1; j < n; j++) {
18            ____________
19        }
20    }
21    return dp[m - 1][n - 1];
22}
23int main() {
24    int m, n;
25    cin >> m >> n;
26    vector<vector<int>> grid(m, vector<int>(n));
27    for (int i = 0; i < m; i++) {
28        for (int j = 0; j < n; j++) {
29            cin >> grid[i][j];
30        }
31    }
32    int result = minPathSum(grid);
33    cout << result << endl;
34    return 0;
35}

(2 分)
GESP 七级 2025-03 · 单选 第13题 | 知识点 程序补全、线性DP
第 14 题 单选 未作答

给定一个整数数组 nums,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。下面横线处应该填入的是( )

01#include <iostream>
02#include <vector>
03#include <algorithm>
04using namespace std;
05int maxSubArray(vector<int>& nums) {
06    int n = nums.size();
07    if (n == 0) return 0;
08    vector<int> dp(n, 0);
09    dp[0] = nums[0];
10    int maxSum = dp[0];
11    for (int i = 1; i < n; i++) {
12        ____________
13        maxSum = max(maxSum, dp[i]);
14    }
15    return maxSum;
16}
17int main() {
18    int n;
19    cin >> n;
20    vector<int> nums(n);
21    for (int i = 0; i < n; i++) {
22        cin >> nums[i];
23    }
24    int result = maxSubArray(nums);
25    cout << result << endl;
26    return 0;
27}

(2 分)
GESP 七级 2025-03 · 单选 第14题 | 知识点 程序补全、线性DP
第 15 题 单选 未作答

在哈希表的实现中,冲突解决是一个重要的问题。以下哪种方法 不是 常见的哈希表冲突解决策略?

(2 分)
GESP 七级 2025-03 · 单选 第15题 | 知识点 哈希表、二分查找
第 16 题 判断 未作答

在C++语法中,表达式 1e6100000010^6 的值是相同的。

(2 分)
GESP 七级 2025-03 · 判断 第1题 | 知识点 位异或、浮点型
第 17 题 判断 未作答

在C++语言中,函数调用前必须有函数声明或定义。

(2 分)
GESP 七级 2025-03 · 判断 第2题 | 知识点 函数定义与调用、C++程序结构
第 18 题 判断 未作答

快速排序一般是不稳定的。

(2 分)
GESP 七级 2025-03 · 判断 第3题 | 知识点 快速排序、排序稳定性
第 19 题 判断 未作答

long long 类型能表达的数都能使用 double 类型精确表达。

(2 分)
GESP 七级 2025-03 · 判断 第4题 | 知识点 浮点型、数据范围与溢出
第 20 题 判断 未作答

使用 math.hcmath 头文件中的函数,表达式 cos(60) 的结果类型为 double 、值约为 0.5

(2 分)
GESP 七级 2025-03 · 判断 第5题 | 知识点 cmath数学函数、浮点型
第 21 题 判断 未作答

一颗NN层的满二叉树,一定有2N12^N - 1个结点。

(2 分)
GESP 七级 2025-03 · 判断 第6题 | 知识点 满二叉树、二叉树性质
第 22 题 判断 未作答

邻接表和邻接矩阵都是图的存储形式。为了操作时间复杂度考虑,同一个图可以同时维护两种存储形式。

(2 分)
GESP 七级 2025-03 · 判断 第7题 | 知识点 邻接矩阵、邻接表
第 23 题 判断 未作答

子类对象包含父类的所有成员(包括私有成员)。从父类继承的私有成员也是子类的成员,因此子类可以直接访问。

(2 分)
GESP 七级 2025-03 · 判断 第8题 | 知识点 继承、类与对象
第 24 题 判断 未作答

动态规划算法通常有递归实现和递推实现。但由于递归调用在运行时会由于层数过多导致程序崩溃,有些动态规划算法只能用递推实现。

(2 分)
GESP 七级 2025-03 · 判断 第9题 | 知识点 线性DP、递归、递推
第 25 题 判断 未作答

按照下面的规则生成一棵二叉树:以一个人为根节点,其父亲为左子节点,母亲为右子节点。对其父亲、母亲分别用同样规则生成左子树和右子树。以此类推,记录30代的直系家谱,则这是一棵满二叉树。

(2 分)
GESP 七级 2025-03 · 判断 第10题 | 知识点 满二叉树、二叉树概念