#6151. gesp三级真题分类三:C++ 基础语法
gesp三级真题分类三:C++ 基础语法
C++ 基础语法(共20题)
- 定义
char str[10] = "GESP",则sizeof(str)的值是( ) {{ select(1) }}
- 4
- 5
- 10
- 不确定
- 下列字符串操作中,会修改原字符串的是( ) {{ select(2) }}
s.substr(1,3)s.find('a')s.replace(0,2,"abc")s.length()
- 定义
int a[5] = {1,2,3},则a[3]的值是( ) {{ select(3) }}
- 0
- 3
- 随机值
- 编译错误
- 执行
string s = "123"; int x = s[0];后,x 的值是( ) {{ select(4) }}
- 1
- '1'
- 49
- 编译错误
- 下列哪种类型转换是隐式转换?( ) {{ select(5) }}
int a = (int)3.14;double b = 5;char c = 'A' + 1;string s = "hello" + "world";
- 下列数组定义中,错误的是( ) {{ select(6) }}
int a[] = {1,2,3};int a[3] = {1,2,3};int a[3] = {1,2,3,4};int a[3] = {0};
- 以下代码输出结果是( )
{{ select(7) }}int a = 3, b = 2; cout << a / b * 1.0;
- 1.5
- 1
- 1.0
- 编译错误
- 下列字符串初始化中,正确的是( ) {{ select(8) }}
string s = 'hello';string s = "hello";string s = hello;string s = 123;
- 对于
int arr[10],下列访问正确的是( ) {{ select(9) }}
arr[0]arr[10]arr[-1]arr[10.5]
- 下列代码输出结果是( )
{{ select(10) }}int a[3] = {1,2,3}; cout << a[1] << endl;
- 1
- 2
- 3
- 随机值
- 字符串
"GESP"和字符数组{'G','E','S','P'}完全等价。( ) {{ select(11) }}
- 正确
- 错误
int a[10] = {0}将数组中所有元素初始化为 0。( ) {{ select(12) }}
- 正确
- 错误
cout << (3/2*1.0)输出1.5。( ) {{ select(13) }}
- 正确
- 错误
string s = "GESP"; s[4]访问不会导致运行时错误。( ) {{ select(14) }}
- 正确
- 错误
char c = 65; cout << c;输出A。( ) {{ select(15) }}
- 正确
- 错误
int a[5];定义后,所有元素的值默认为 0。( ) {{ select(16) }}
- 正确
- 错误
string s = "Hello"; s.length()和s.size()返回值相同。( ) {{ select(17) }}
- 正确
- 错误
int a[3] = {1,2};中,a[2]的值是 0。( ) {{ select(18) }}
- 正确
- 错误
char str[5] = "GESP";中,str[4]的值是'\0'。( ) {{ select(19) }}
- 正确
- 错误
cout << "GESP" << endl;会输出 GESP 并换行。( ) {{ select(20) }}
- 正确
- 错误