#fx1002. 府学寒假测试
府学寒假测试
- 若定义int a[2][3] = {{1,2}, {3}};,则a[0][2]的值是( ) {{ select(1) }}
- 0
- 1
- 2
- 未定义
- 定义int a[3][4];,数组元素总数是( )。
{{ select(2) }}
- 3
- 4
- 7
- 12
- 常量 7.0 的数据类型是( )。
{{ select(3) }}
- double
- float
- void
- int
- 下列关于 C++语言的叙述,不正确的是( )。
{{ select(4) }}
- 变量定义时可以不初始化
- 变量被赋值之后的类型不变
- 变量没有定义也能够使用
- 变量名必须是合法的标识符
- 以下不可以作为 C++标识符的是( )。
{{ select(5) }}
- x321
- 0x321
- x321_
- _x321
- 以下哪个不是 C++语言的关键字( ).
{{ select(6) }}
- int
- for
- do
- cout
- 以下初始化方式错误的是( )。
{{ select(7) }}
-
int a[2][3] = {0};
-
int a[][3] = {1,2,3,4};
-
int a[2][] = {{1,2}, {3,4}};
-
int a[2][3] = {{1}, {2,3}};
- 如果用两个 int 类型的变量 a 和 b 分别表达长方形的长和宽,则下列哪个表达式不能用来计算长方形的周长( )?
{{ select(8) }}
- a + b * 2
- 2 * a + 2 * b
- a + b + a + b
- b + a * 2 + b
- 若int a[2][3] = {0};,则所有元素值为( )。
{{ select(9) }}
- 全部1
- 全部0
- 随机值
- 编译错误
- 如果 a 为 int 类型的变量,且 a 的值为 6,则执行 a *= 3; 之后,a 的值会是( )。
{{ select(10) }}
- 3
- 6
- 9
- 18
- 以下哪一个是合法的一维数组定义( )。 {{ select(11) }}
- int arr[];
- int arr[5] = {1, 2, 3};
- int arr(5);
- arr[5] = int;
- 若有 int a[4] = {10, 20, 30}; a[3]的值是多少( )。 {{ select(12) }}
- 0
- 随机值
- 编译错误
- 30
- 以下代码的输出是( ) 。
int i = 5;
while (i > 0) {
cout << i << " ";
i--;
}
{{ select(13) }}
- 5 4 3 2 1
- 5 4 3 2 1 0
- 4 3 2 1
- 无限循环
- 在下列代码的横线处填写( ),可以使得输出是 "1248" 。
1 #include <iostream>
2 using namespace std;
3 int main() {
4 for (int i = 1; i <= 8; _______) // 在此处填入代码
5 cout << i;
6 return 0;
7 }
{{ select(14) }}
- i++
- i *= 2
- i += 2
- i * 2
- 以下 while循环会执行多少次?(假设 int i = 0;)( )。
while (i < 3) {
cout << i << " ";
i++;
}
{{ select(15) }}
- 2
- 3
- 4
- 无限次