#81. [GESP202312 四级] 客观题

[GESP202312 四级] 客观题

一、单选题(每题2分,共30分)

第1题. 下⾯有关函数参数的说法,正确的是( )。

{{ select(1) }}

  • 函数参数传递时,主函数当中采⽤值传递⽅式将参数传递给⼦函数时,若⼦函数将参数值改变,主函数当中的参数值不变
  • 函数参数传递时,主函数当中采⽤值传递⽅式将参数传递给⼦函数时,若⼦函数将参数值改变,主函数当中的参数值将随⼦函数⼀样改变⽽改变
  • 函数参数传递时,主函数如果将参数的地址传递给⼦函数,若⼦函数将参数值改变,主函数当中的参数值将不改变
  • 函数参数传递可以不满⾜⼦函数的参数个数要求

第2题. 下⾯C++代码执⾏后,输出的是( )

int arr[10]={1};
string strArr="chen a dai";
cout<<strArr[arr[1]]<<endl;

{{ select(2) }}

  • chen
  • c
  • chen a dai
  • dai

第3题. 下⾯C++代码最后执⾏后输出是( )。

#include
using namespace std;
int fun1(int *n){
	return *n**n;
}
int main(){
	int arr[10]={2};;
	arr[1]=fun1(arr);
	cout<<arr[1]<<endl;
	return 0;
}

{{ select(3) }}

  • 1
  • 2
  • 3
  • 4

第4题. 下⾯C++代码执⾏后的结果是( )。

int arr[3][3]={{1,2,3},{4,5,6},{7,8,9}};
for(int i=0;i<3;i++){
	for(int j=2;j>=0;j--){
		cout<<arr[i][j]<<" ";
	}
	cout<<endl;
}

{{ select(4) }}

  • 1 2 3
    4 5 6
    7 8 9
    
  • 1 2 3 4 5 6 7 8 9
    
  • 3 2 1
    6 5 4
    9 8 7
    
  • 9 8 7 6 5 4 3 2 1
    

第5题. 下⾯C++代码执⾏后输出是( )。

int arr[3]={1,2,3};
int *p=NULL;
p=arr;
p++;
cout<<*p<<endl;

{{ select(5) }}

  • 1,2,3
  • 1
  • 2
  • 3

第6题. 如果变量x的地址是0x6ffe14,下⾯C++代码执⾏以后输出的是( )。

int *p=NULL;
int x=2;
p=&x;
p++;
cout<<p<<endl;

{{ select(6) }}

  • 0x6ffe11
  • 0x6ffe14
  • 0x6ffe18
  • 0x6ffe15

第7题. 在C++中,执⾏下⾯代码后,输出的是( )。

#include<iostream>
using namespace std;
int point(int *p){
	return *p**p;
}
int main() {
	int a=20;
	int *p=&a;
	*p=point(p);
	cout<<*p<<endl;
	return 0;
}

{{ select(7) }}

  • 400
  • 200
  • 20
  • 100

第8题. 下列C++语句执⾏以后结果是true的是( )。

{{ select(8) }}

  • 3&&false
  • 5&&2
  • 101&&000
  • 4&true

第9题. 在如下的C++代码中实现了对字符串中出现的26个字母的个数统计,横线处应填⼊是( )。

#include<iostream>
using namespace std;
int main() {
	string str="HELLO CHEN A DAI";
	int strlen=str.length();
	char alpha[26]={65};
	int cnt[26]={0};
	for(int i=1;i<26;i++){
		alpha[i]=alpha[i-1]+1;
	}
	for(int i=0;i<26;i++){
		cout<<alpha[i]<<" ";
	} 
	cout<<endl;
	for(int i=0;i<26;i++){
		for(int j=0;j<strlen;j++){
			if(alpha[i]==str[j]){
				cnt[i]++;
			}
		}
	}
	for(int i=0;i<26;i++){
		cout<<cnt[i]<<" ";
	}
	return 0;
}

{{ 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;

第10题. 下⾯C++代码执⾏后⽣成的⽂件其字节数为( )。

ofstream fout;
fout.open("1.txt");
for(int i=1; i<=10; i++) {
	if(i%5==0) {
		int x=6;
		fout<<x;
	} else {
		char ch='A';
		fout<<ch;
	}
}

{{ select(10) }}

  • 10
  • 16
  • 40
  • 24

第11题. 下列C++代码输⼊ 1,2,3,4 ,执⾏后,将输出的是( )。

string str="";
cin>>str;
int strlen=str.length();
for(int i=0; i<strlen; i++) {
	if(str[i]<='9' && str[i]>='0') {
		cout<<str[i];
	} else {
		cout<<"#";
	}
}

{{ select(11) }}

  • 1#4#
  • 1#3#
  • 1#2#3#4#
  • 1#2#3#4

第12题. ⼀以下C++代码⽤于实现每个整数对应的因数,如输⼊ 12 ,则输出 1 2 3 4 6 12 ;如输⼊ 18 ,则输出 1 2 3 6 9 18 。横线处应填⼊代码是( )。

int n;
cin>>>n;
for(int i=1;i<=n;i++){
	________   //在此处填入代码
	{
		cout<<i<<" ";
	}
}

{{ select(12) }}

  • if(n%i==0)
  • if(n/i==0)
  • if(n%i!=0)
  • if(n/i!=0)

第13题. 某公司新出了⼀款⽆⼈驾驶的⼩汽车,通过声控智能驾驶系统,乘客只要告诉汽车⽬的地,车⼦就能⾃动选择⼀条优化路线,告诉乘客后驶达那⾥。请问下⾯哪项不是驾驶系统完成选路所必须的。( )。

{{ select(13) }}

  • 麦克风
  • 扬声器
  • 油量表
  • 传感器

第14题. 现代计算机是指电⼦计算机,它所基于的是( )体系结构。

{{ select(14) }}

  • 艾伦·图灵
  • 冯·诺依曼
  • 阿塔纳索夫
  • 埃克特-莫克利

第15题. 输入一个正整数N(N>=7),想找出它所有相邻的因数对,比如,输入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);
    

二、判断题(每题2分,共20分)

第16题. C++的内置函数 sort() ⽀持数组的局部排序。例如 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) }}

  • ×

第17题. ⽤递归法求 的阶乘,时间复杂度是O(n)。( ) {{ select(17) }}

  • ×

第18题. [(1,2)*2]*3 在C++中是合法的表达式。( )

{{ select(18) }}

  • ×

第19题. 在下⾯的C++代码中,将对1.txt⽂件写⼊ hello。( )

ifstream filein;
ofstream fileout;
filein.open("1.txt");
fileout<<"hello";

{{ select(19) }}

  • ×

第20题. ⽂本⽂件 1.txt 第1⾏由 01234 共5个字符组成其间没有空格,当⽤C++代码正常打开⽂件成功并执⾏如下代码以后,第1⾏长度为5( )

ifstream filein;
int buff;
filein.open("1.txt");
filein>>buff;
cout<<buff<<endl;

{{ select(20) }}

  • ×

第21题. 执⾏C++代码 cout<<(5||2); 后将输出 1 。( )

{{ select(21) }}

  • ×

第22题. 在C++中,两个字符串相加的运算符为+相当于字符串的合并运算。下⾯C++代码执⾏后,将输出 chenadai。( )

string a="chen";
string b="a";
string c="dai";
string name=a+b+c;
cout<<name<<endl; 

{{ select(22) }}

  • ×

第23题. C++内置函数 sort() 可以对整数、浮点数、字符数组进⾏从⼤到⼩,从⼩到⼤,局部排序。( )

{{ select(23) }}

  • ×

第24题. ⼩杨最近在准备考GESP,他⽤的Dev C++来练习和运⾏程序,所以Dev C++也是⼀个⼩型操作系统。( )

{{ select(24) }}

  • ×

第25题. 任何⼀个while循环都可以转化为等价的for循环。( )

{{ select(25) }}

  • ×