#83. GESP C++ 三级 2023年12月(客观题)
GESP C++ 三级 2023年12月(客观题)
一、单选题(每题2分,共30分)
第1题. 下面C++数组的定义中,会丢失数据的是( )。
{{ select(1) }}
- char dict_key[] = {‘p’,‘t’,‘o’};
- int dict_value[] = {33,22,11};
- char dict_name[]={‘chen’,‘wang’,‘zhou’};
- float dict_value[]={3,2,1};
第2题. 在下列编码中,不能够和二进制"1101 1101"相等的是( )。
{{ select(2) }}
- (221)10进制
- (335)8进制
- (dd)16进制
- (5d)16进制
第3题. 下面C++代码执行后不能输出"GESP"的是( )。
{{ select(3) }}
- string str(“GESP”); cout<<str<<endl;
- string str=“GESP”; cout<<str<<endl;
- string str(“GESP”); cout<<str[1]<<str[2]<<str[3]<<str[4]<<endl;
- string str{“GESP”}; cout<<str<<endl;
第4题. 执行下面C++代码输出是( )。
int temp=0;
for(int i=1;i<7;i++)
{
for(int j=1;j<5;j++)
{
if(i/j==2)
{
temp++;
}
}
}
cout<<temp<<endl;
{{ select(4) }}
- 10
- 8
- 4
- 3
第5题. 执行下面C++代码后,输出是( )。
string str=("chen");
int x=str.length();
int temp=0;
for(int i=0;i<=x;i++)
{
temp++;
}
cout<<temp<<endl;
{{ select(5) }}
- 4
- 2
- 5
- 3
第6题. 执行下面C++代码后输出的是( )。
string str=("chen");
int x=str.length( );
cout<<x<<endl;
{{ select(6) }}
- 4
- 3
- 2
- 5
第7题. 执行下面C++代码后输出的是( )。
string str = ("chen");
cout << str[5] << endl;
{{ select(7) }}
- 输出未知的数
- 输出’n’
- 输出’\0’
- 输出空格
第8题. 下面C++代码执行后的输出是( )。
char ch[10] = {'1'};
cout << ch[2] << endl ;
{{ select(8) }}
- 0
- 1
- 输出空格
- 什么也不输出
第9题. 下面C++代码用于统计每种字符出现的次数,当输出为3时,横线上不能填入的代码是( )。
string str="GESP is a good programming test!";
int x=0;
for(int i=0;i<str.length( );i++)
{
if(__________)
{
×++;
}
}
cout<<x<<endl;
{{ select(9) }}
- str[i]==‘o’
- str[i]==‘a’+14
- str[i]==115
- str[i]==111
第10题. 32位计算机中,C++的整型变量int能够表示的数据范围是( )。
{{ select(10) }}
- 2^31~(2^31)-1
- 2^32
- -2^31~+(2^31)-1
- -(2^31)+1~2^31
第11题. 下面C++程序执行的结果是( )。
int cnt=0;
for(int i=0;i<=20;i++)
{
if(i%3==0&&i%5==0)
{
cnt++;
}
}
cout<<cnt;
{{ select(11) }}
- 2
- 3
- 5
- 4
第12题. C++的数据类型转换让人很难琢磨透,下列代码输出的值是( )。
int a = 3;
int b = 2;
cout << a / b *1.0 << endl;
{{ select(12) }}
- 1.5
- 1
- 2
- 1.50
第13题. C++代码用于抽取字符串中的电话号码。约定:电话号码全部是数字,数字之间没有其他符号如连字符或 空格等。代码中变量strSrc仅仅是示例,可以包含更多字符。下面有关代码说法,正确的说法是( )。
string strSrc=" 红十字:01084025890火警电话:119急救电话:120紧急求助:110";
string tel="";
for(int i=0; i<=strSrc.length(); i++) {
if(strSrc[i]>='0' && strSrc[i]<='9') {
tel=tel+strSrc[i];
} else if(tel != "") {
cout<<tel<<endl;
tel="";
}
}
{{ select(13) }}
- 代码将换行输出各个含有数字的电话号码。
- 代码将不换行输出各个含有数字的电话号码,号码中间没有分隔。
- 代码将不换行输出各个含有数字的电话号码,号码中间有分隔。
- 不能够输出数字电话号码。
第14题. 某公司新出了一款无人驾驶的小汽车,通过声控智能驾驶系统,乘客只要告诉汽车目的地,车子就能自动 选择一条优化路线,告诉乘客后驶达那里。请问下面哪项不是驾驶系统完成选路所必须的。( )
{{ select(14) }}
- 麦克风
- 扬声器
- 油量表
- 传感器
第15题. 现代计算机是指电子计算机,它所基于的是( )体系结构。
{{ select(15) }}
- 艾伦·图灵
- 冯·诺依曼
- 阿塔纳索夫
- 埃克特-莫克利
二、判断题(每题2分,共20分)
第16题. 执行C++代码 cout<<(5&&2)<<endl; 后将输出 1 。( )
{{ select(16) }}
- √
- ×
第17题. C++程序执行后,输入 chen a dai 输出应该为: chen 。( )
string str;
cin >> str;
cout << str;
{{ select(17) }}
- √
- ×
第18题. 执行C++代码 cout<<( 5 | | 2 ); 后将输出 1 。( )
{{ select(18) }}
- √
- ×
第19题. 执行下面C++代码后将输出"China"。( )
string a="china";
a.replace(0,1,"C");
cout<<a<<endl;
{{ select(19) }}
- √
- ×
第20题. 执行C++代码将输出0 5 ,5 之后还有一个空格。( )
int list[10]={1,2,3,4,5,6,7,8,9,10};
for(int i=0;i<10;i++)
{
if(i%5==0)
{
cout<<list[i]<<"";
}
}
{{ select(20) }}
- √
- ×
第21题. 下面C++代码将输出1( )
int list[10]={1};
cout<<list<<endl;
{{ select(21) }}
- √
- ×
第22题. 下面C++程序将输出1。( )
int arr[10]={1};
cout<<arr[0]<<endl;
{{ select(22) }}
- √
- ×
第23题. 执行C++代码,将输出1 3 5 7 9 ,9 之后还有一个空格。( )
int list[10] = {1,2,3,4,5,6,7,8,9,10};
for(iny i=0;i<10;i+=2)
{
cout << list[i] << " ";
}
{{ select(23) }}
- √
- ×
第24题. 小杨最近在准备考GESP,他用的Dev C++来练习和运行程序,所以Dev C++也是一个小型操作系统。( )
{{ select(24) }}
- √
- ×
第25题. 任何一个while循环都可以转化为等价的for循环( )。
{{ select(25) }}
- √
- ×