#GESP2024064K. GESP-C++ 四级客观题202406K
GESP-C++ 四级客观题202406K
一、单选题(每题 分,共 分)
下列代码中,输出结果是( )
01 #include<iostream>
02 using namespace std;
03 int func(int x, int y) {
04 int a = x, b = y;
05 int t;
06 t = a;
07 a = b;
08 b = t;
09 cout << a << " " << b << " ";
10 }
11 int main() {
12 int c, d;
13 c = 12;
14 d = 24;
15 func(12, 24);
16 cout << c << " " << d << endl;
17 }
{{ select(1) }}
12 24 24 12
24 12 12 24
12 12 24 24
24 24 12 12
下面函数不能正常执行的是()
{{ select(2) }}
下面程序输出的是()
01 #include<iostream>
02 using namespace std;
03 int func();
04 int main() {
05 int i = 2;
06 cout << i << endl;
07 for (int x = 0; x < 1; x++) {
08 int i = 10;
09 cout << i << endl;
10 }
11 i = i + 1;
12 cout << i << endl;
13 {
14 i = i*i;
15 cout << i << endl;
16 }
17 }
{{ select(3) }}
2 2 3 9
2 10 3 9
2 10 11 121
2 10 3 100
假设变量 的地址是 0x6ffe14
,下面程序的输出是( )。
01 #include<iostream>
02 using namespace std;
03 int main() {
04 int *p;
05 int a = 10;
06 p = &a;
07 p++;
08 cout << p << endl;
09 }
{{ select(4) }}
10
0x6ffe14
0x6ffe15
0x6ffe18
如果下列程序输出的地址是 0x6ffe00
,则 cout<<a+1<<endl;
输出的是()
01 #include<iostream>
02 using namespace std;
03 int main() {
04 int a[2][3] = {0};
05 cout << a << endl;
06 }
{{ select(5) }}
0x6ffe04
0x6ffe0C
0x6ffe08
0x6ffe00
中,关于文件路径说法错误的是()
{{ select(6) }}
"GESP.txt"
:指定与当前工作目录中的程序文件相同目录中的GESP.txt
文件"../data/GESP.txt"
:指定与当前工作目录中的程序文件上一级目录下的data
目录中的GESP.txt
文件"./data/GESP.txt"
:指定与当前工作目录中的程序文件同级目录下的data
目录中的GESP.txt
文件"GESP.txt"
是绝对路径
关于直接插入排序,下列说法错误的是()
{{ select(7) }}
- 插入排序的最好情况是数组已经有序,此时只需要进行 次比较,时间复杂度为
- 最坏情况是数组逆序排序,此时需要进行 次比较以及 次赋值操作(插入)
- 平均来说插入排序算法的复杂度为
- 空间复杂度上,直接插入法是就地排序,空间复杂度为
下列程序横线处,应该输入的是 ( )。
01 #include<iostream>
02 using namespace std;
03 int n, a[10001];
04 void swap(int &a, int &b) {
05 int t = a;
06 a = b;
07 b = t;
08 }
09
10 int main() {
11 cin >> n;
12 for (int i = 1; i <= n; i++)
13 cin >> a[i];
14 for (int i = n; i > 1; i--)
15 for (int j = 1; j < i; j++)
16 if (a[j] > a[j + 1])
17 _______________;
18 for (int i = 1; i <= n; i++)
19 cout << a[i] << " ";
20 cout << endl;
21 return 0;
22 }
{{ select(8) }}
swap(a[j],a[j+1]);
swap(a[j-1],a[j]);
swap(a[j-1],a[j+1]);
swap(&a[j-1],&a[j+1]);
下面关于递推的说法不正确的是( )。
{{ select(9) }}
- 递推表现为自己调用自己
- 递推是从简单问题出发,一步步的向前发展,最终求得问题。是正向的
- 递推中,问题的 要求是在计算中确定,不要求计算前就知道
- 斐波那契数列可以用递推实现求解
关于几种排序算法的说法,下面说法错误的是( )。
{{ select(10) }}
- 选择排序不是一个稳定的排序算法
- 冒泡排序算法不是一种稳定的排序算法
- 插入排序是一种稳定的排序算法
- 如果排序前 个相等的数在序列中的前后位置顺序和排序后它们 个的前后位置顺序相同,则称为一种稳定的 排序算法
数组 {45,66,23,1,10,97,52,88,5,33}
进行从小到大冒泡排序过程中,第一遍冒泡过后的序列是( )。
{{ select(11) }}
{45,23,1,10,66,52,88,5,33,97}
{45,66,1,23,10,97,52,88,5,33}
{45,66,23,1,10,52,88,5,33,97}
{45,66,23,1,10,97,52,88,33,5}
下面的排序算法程序中,横线处应该填入的是( )。
01 int a[8] = { 2, 3, 4, 5, 6, 2, 3, 1};
02 for (int i = 1; i < 8; i++) {
03 int key = a[i];
04 int j = i - 1;
05 while (a[j] > key && j >= 0) {
06 ________;
07 j -= 1;
08 }
09 a[j + 1] = key;
10 }
{{ select(12) }}
a[j]=a[j-1];
a[j]=a[j+1];
a[j+1]=a[j-1];
a[j+1]=a[j];
下面的程序中,如果输入 10 0
,会输出( )。
01 #include<iostream>
02 using namespace std;
03
04 double Division(int a, int b) {
05 if (b == 0)
06 throw "Division by zero condition!";
07
08 else
09 return ((double)a / (double)b);
10 }
11
12 void func() {
13 int len, time;
14 cin >> len >> time;
15 cout << Division(len, time) << endl;
16 }
17
18 int main() {
19 try {
20 func();
21 } catch (const char* errmsg) {
22 cout << errmsg << endl;
23 } catch (const int errmsg) {
24 cout << errmsg << endl;
25 }
26 return 0;
27 }
{{ select(13) }}
Division by zero condition!
0
10
100
条直线,最多可以把平面分为多少个区域( )。
{{ select(14) }}
55
56
54
58
下面程序中,如果语句 cout<<p<<endl;
输出的是 0x6ffe00
,则 cout<<++p<<endl;
输出的是()
01 int x[10][10][10] = {{0}};
02 int *p;
03 p = &x[0][0][0];
04 cout << p << endl;
05 cout << ++p << endl;
{{ select(15) }}
0x6ffe0c
0x6ffe09
0x6ffe06
0x6ffe04
二、判断题(每题 分,共 分)
int& a
和 &a
是一样的,都是取 的地址
{{ select(16) }}
- 正确
- 错误
以下代码不能够正确执行。
01 #include<iostream>
02 using namespace std;
03
04 int main()
05 {
06 int a=20;
07 int& ra;
08 ra=&a;
09 cout<<ra<<endl;
10 }
{{ select(17) }}
- 正确
- 错误
引用是一个指针常量。
{{ select(18) }}
- 正确
- 错误
下面程序两个输出结果是一样的。
01 #include<iostream>
02 using namespace std;
03
04 int main() {
05 int a[2][3] = {0};
06 cout << a << endl;
07 cout << &a[0][0] << endl;
08 }
{{ select(19) }}
- 正确
- 错误
函数不可以调用自己。
{{ select(20) }}
- 正确
- 错误
函数参数传递过程中,如果传常量值、常量引用和常量指针都是不能被修改的,它们可以防止函数对实参的值或地址进行修改。
{{ select(21) }}
- 正确
- 错误
下面代码输出的值等于 。
01 #include<iostream>
02 using namespace std;
03
04 int main() {
05 int *p = NULL;
06 cout << p << endl;
07 }
{{ select(22) }}
- 正确
- 错误
在下面这个程序里, a[i][j]
和一个普通的整型变量一样使用
01 #include<iostream>
02 using namespace std;
03
04 int main() {
05 int a[10][10] = {0};
06 for (int i = 0; i < 10; i++) {
07 for (int j = 0; j < 10; j++) {
08 if (i == j) {
09 a[i][j] = 1;
10 }
11 }
12 }
13 }
{{ select(23) }}
- 正确
- 错误
一个一维数组,至少含有一个自然数 ,是一个合法的数列。可以在一维数组末尾加入一个自然数 , 不能超过一维数组末尾元素的一半,形成一个新的合法的一维数组,如果 N=6
,那么可以有 个不同的合法数组。
{{ select(24) }}
- 正确
- 错误
插入排序算法中,平均时间复杂度是 ,最坏的情况逆序情况下,达到最大时间复杂度。
{{ select(25) }}
- 正确
- 错误