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