#GESP2023124K. GESP-C++ 四级客观题202312K
GESP-C++ 四级客观题202312K
一、单选题(每题 分,共 分)
下面有关函数参数的说法,正确的是( )。
{{ select(1) }}
- 函数参数传递时,主函数当中采用值传递方式将参数传递给子函数时,若子函数将参数值改变,主函数当中的参数值不变。
- 函数参数传递时,主函数当中采用值传递方式将参数传递给子函数时,若子函数将参数值改变,主函数当中的参数值将随子函数一样改变而改变。
- 函数参数传递时,主函数如果将参数的地址传递给子函数,若子函数将参数值改变,主函数当中的参数值将不改变。
- 函数参数传递可以不满足子函数的参数个数要求。
下面 代码执行后,输出的是( )。
01 int arr[10] = {1};
02 string strArr = "chen a dai" ;
03 cout << strArr[arr[1]] << endl ;
{{ select(2) }}
chen
c
chen a dai
dai
下面 代码最后执行后输出是( )。
01 int fun1(int *n) {
02 return *n**n;
03 }
04 int main() {
05 int arr[10] = {2};
06 arr[1] = fun1(arr);
07 cout << arr[1] << endl;
08 }
{{ select(3) }}
1
2
3
4
下面 代码执行后的结果是( )。
01 int arr[3][3] = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
02 for (int i = 0; i < 3; i++) {
03 for (int j = 2; j >= 0; j--) {
04 cout << arr[i][j] << " ";
05 }
06 cout << endl;
07 }
{{ select(4) }}
下面 代码执行后输出是( )。
01 int arr[3] = {1, 2, 3};
02 int *p = NULL;
03 p = arr;
04 p++;
05 cout << *p << endl;
{{ select(5) }}
1,2,3
1
2
3
如果变量 的地址是 0x6ffe14
,下面 代码执行以后输出的是( )。
01 int*p = NULL;
02 int x = 2;
03 p = &x;
04 p++;
05 cout << p << endl;
{{ select(6) }}
0x6ffe11
0x6ffe14
0x6ffe18
0x6ffe15
在 中,执行下面代码后,输出的是( )。
01 int point(int *p) {
02 return *p**p;
03 }
04
05 int main() {
06 int a = 20;
07 int *p = &a;
08 *p = point(p);
09 cout << *p << endl;
10 }
{{ select(7) }}
400
200
20
100
下列 语句执行以后结果是 true
的是( )。
{{ select(8) }}
3&&false
5&&2
101&&000
4&true
在如下的 代码中实现了对字符串中出现的 个字母的个数统计,横线处应填入是( )。
01 string str = "HELLO CHEN A DAI";
02 int strlen = str.length();
03 char alpha[26] = {65};
04 int cnt[26] = {0};
05 for (int i = 1; i < 26; i++) {
06 _____________;
07 }
08 for (int i = 0; i < 26; i++) {
09 cout << alpha[i] << " ";
10 }
11 cout << endl;
12 for (int i = 0; i < 26; i++) {
13 for (int j = 0; j < strlen; j++) {
14 if (alpha[i] == str[j]) {
15 cnt[i]++;
16 }
17 }
18 }
19 for (int i = 0; i < 26; i++) {
20 cout << cnt[i] << " ";
21 }
{{ select(9) }}
alpha[i]=alpha[i-1]+1;
alpha[i]=alpha[i]+1;
alpha[i+1]=alpha[i]+1;
alpha[i-1]=alpha[i]+1;
下面 代码执行后生成的文件其字节数为( )。
01 ofstream fout;
02 fout.open("1.txt");
03 for (int i = 1; i <= 10; i++) {
04 if (i % 5 == 0) {
05 int x = 6;
06 fout << x;
07 } else {
08 char ch = 'A';
09 fout << ch;
10 }
11 }
{{ select(10) }}
10
16
40
24
下列 代码输入 1,2,3,4
,执行后,将输出的是( )。
01 string str = "";
02 cin >> str;
03 int strlen = str.length();
04 for (int i = 0; i < strlen; i++) {
05 if (str[i] <= '9' && str[i] >= '0') {
06 cout << str[i];
07 } else {
08 cout << "#";
09 }
10 }
{{ select(11) }}
1#4#
1#3#
1#2#3#4#
1#2#3#4
以下 代码用于实现每个整数对应的因数,如输入 12
,则输出 1 2 3 4 6 12
;如输入 18
,则输出 1 2 3 6 9 18
。横线处应填入代码是( )。
01 int n;
02 cin >> n;
03 for (int i = 1; i <= n; i++) {
04 ____________ {
05 cout << i << " ";
06 }
07 }
{{ select(12) }}
if(n%i==0)
if(n/i==0)
if(n%i!=0)
if(n/i!=0)
某公司新出了一款无人驾驶的小汽车,通过声控智能驾驶系统,乘客只要告诉汽车目的地,车子就能自动选择一条优化路线,告诉乘客后驶达那里。请问下面哪项不是驾驶系统完成选路所必须的。( )
{{ select(13) }}
- 麦克风
- 扬声器
- 油量表
- 传感器
现代计算机是指电子计算机,它所基于的是( )体系结构
{{ select(14) }}
- 艾伦·图灵
- 冯·诺依曼
- 阿塔纳索夫
- 埃克特-莫克利
输入一个正整数 (),想找出它所有相邻的因数对,比如,输入 12
,因数对有 (1,2)、(2,3)、(3.4)
。下面哪段代码找不到所有的因数对?()
{{ select(15) }}
for(i=1;i<N;i++) if(!(N%i) && !(N%(i+1))) printf("(%d,%d)\n", i, i+1);
for(i=2;i<N;i++) if(!(N%i) && !(N%(i+1))) printf("(%d,%d)\n", i, i+1);
for(i=2;i<N/2;i++) if(!(N%(i-1)) && !(N%i)) printf("(%d,%d)\n", i-1, i);
for(i=1;i<N/2;i++) if(!(N%i) && !(N%(i+1))) printf("(%d,%d)\n", i, i+1);
二、判断题(每题 分,共 分)
的内置函数 支持数组的局部排序。例如 int a={10,9,8,7,6,5,4,3,2,1}
,可以用sort(a,a+5)
,排序成 {6,7,8,9,10,5,4,3,2,1}
。( )
{{ select(16) }}
- 正确
- 错误
用递归法求 的阶乘,时间复杂度是。
{{ select(17) }}
- 正确
- 错误
[(1,2)*2]*3
在 中是合法的表达式。( )
{{ select(18) }}
- 正确
- 错误
在下面的 代码中,将对 1.txt
文件写入 hello
。( )
01 ifstream filein;
02 ofstream fileout;
03 filein.open("1.txt");
04 fileout << "hello";
{{ select(19) }}
- 正确
- 错误
文本文件 1.txt
第 行由 01234
共 个字符组成其间没有空格,当用 代码正常打开文件成功并执行如下代码以后,第 行长度为 ( )
01 ifstream filein;
02 int buff;
03 filein.open("1.txt");
04 filein >> buff;
05 cout << buff << endl;
{{ select(20) }}
- 正确
- 错误
执行 代码 cout<<(5||2);
后将输出 1 。( )
{{ select(21) }}
- 正确
- 错误
在 中,两个字符串相加的运算符为 相当于字符串的合并运算。下面 代码执行后,将输出chenadai 。( )
01 string a = "chen";
02 string b = "a";
03 string c = "dai";
04 string name = a + b + c;
05 cout << name << endl;
{{ select(22) }}
- 正确
- 错误
内置函数 可以对整数、浮点数、字符数组进行从大到小,从小到大,局部排序。( )
{{ select(23) }}
- 正确
- 错误
小杨最近在准备考 ,他用的 Dev C++
来练习和运行程序,所以 Dev C++
也是一个小型操作系统。( )
{{ select(24) }}
- 正确
- 错误
任何一个 while
循环都可以转化为等价的 for
循环( )。
{{ select(25) }}
- 正确
- 错误