理论卷2025年9月GESP等级认证(C++) · 四级
GESP C++ 4级 2025.09
满分 100 · 及格 60 · 时长 60 分钟 · 共 27 题 (单选15 / 判断10 / 编程题2)
试卷阅览 · 免费预览前 10 题 · 交卷后可查看答案与解析
1
单选题号 #11160
分值 2运行下面程序后变量 a 的值是 ( )。
int a = 42;
int* p = &a;
*p = *p + 1;
A
B
C
编译错误
D
不确定
2
单选题号 #11161
分值 2以下关于数组的描述中,( ) 是错误的。
A
数组名是一个指针常量
B
随机访问数组的元素方便快捷
C
数组可以像指针一样进行自增操作
D
sizeof(arr) 返回的是整个数组 arr 占用的字节数
3
单选题号 #11162
分值 2给定如下定义的数组 arr,则 *(*(arr + 1) + 2) 的值是 ( )。
int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};
A
B
C
D
4
单选题号 #11163
分值 2下面这段代码会输出 ( )。
int add(int a, int b = 1); // 函数声明
int main() {
cout << add(2) << " " << add(2, 3);
return 0;
}
int add(int a, int b) { // 函数定义
return a + b;
}
A
3 5
B
编译失败:定义处少了默认参数
C
运行错误
D
链接失败:未定义引用
5
单选题号 #11164
分值 2下面这段代码会输出 ( )。
int x = 5;
void foo() {
int x = 10;
cout << x << " ";
}
void bar() {
cout << x << " ";
}
int main() {
foo();
bar();
}
A
B
C
D
6
单选题号 #11165
分值 2下面程序运行的结果是 ( )。
void increaseA(int x) {
x++;
}
void increaseB(int* p) {
(*p)++;
}
int main() {
int a = 5;
increaseA(a);
cout << a << " ";
increaseB(&a);
cout << a;
return 0;
}
A
B
C
D
7
单选题号 #11166
分值 2关于结构体初始化,以下哪个选项中正确的是 ( )。
struct Point {int x, y;};
A
Point p = (1, 2);
B
Point p = {1, 2};
C
Point p = new {1, 2};
D
Point p = ;
8
单选题号 #11167
分值 2运行如下代码会输出 ( )。
struct Cat {
string name;
int age;
};
void birthday(Cat& c) {
c.age++;
}
int main() {
Cat kitty{"Mimi", 2};
birthday(kitty);
cout << kitty.name << " " << kitty.age;
return 0;
}
A
Mimi 2
B
Mimi 3
C
kitty 3
D
kitty 2
9
单选题号 #11168
分值 2关于排序算法的稳定性,以下说法错误的是 ( )。
A
稳定的排序算法不改变相等元素的相对位置
B
冒泡排序是稳定的排序算法
C
选择排序是稳定的排序算法
D
插入排序是稳定的排序算法
10
单选题号 #11169
分值 2下面代码试图实现选择排序,使其能对数组 nums 排序为升序,则横线上应分别填写 ( )。
void selectionSort(vector& nums) {
int n = nums.size();
for (int i = 0; i < n - 1; ++i) {
int minIndex = i;
for (int j = i + 1; j < n; ++j) {
if ( __________ ) { // 在此处填入代码
minIndex = j;
}
}
____________________; // 在此处填入代码
}
}
A
nums[j] < nums[minIndex]
swap(nums[i], nums[minIndex])
B
nums[j] > nums[minIndex]
swap(nums[i], nums[minIndex])
C
nums[j] <= nums[minIndex]
swap(nums[j], nums[minIndex])
D
nums[j] <= nums[minIndex]
swap(nums[i], nums[j])
🔒
已解锁前 10 题
第 11~27 题(共 17 题)可在考试中作答
本卷为普通试卷:注册用户每题扣 1 积分(每日登录送 30 体验积分),交卷后查看答案与解析
