#480. 2026信息素养C++模拟题(二)
2026信息素养C++模拟题(二)
单选题(每题 5 分,共 100 分)
- 丝绸之路上,商队需要依次访问 个驿站。以下循环会执行多少次?
for(int i = 1; i <= 5; i++) { }
{{ select(1) }}
- 次
- 次
- 次
- 无限次
- 驿站需要计算 到 的累加和。以下代码的输出是什么?
int sum = 0;
for(int i = 1; i <= 10; i++) {
sum += i;
}
{{ select(2) }}
- 商队需要在货物列表中查找特定商品。以下哪个循环结构至少会执行一次?
{{ select(3) }}
for循环while循环do-while循环- 递归调用
- 驿站需要逐个输出货物的编号: , , , , 。以下代码的输出是什么?
int i = 1;
while(i <= 5) {
cout << i << " ";
i++;
}
{{ select(4) }}
1 2 3 41 2 3 4 50 1 2 3 41 2 3 4 5 6
switch语句中,用于终止case执行的关键字是?
{{ select(5) }}
stopexitbreakcontinue
- 商队根据货物类型输出不同提示,使用
if-else结构。以下代码的输出是什么?
int type = 2;
if(type == 1) {
cout << "丝绸";
} else if(type == 2) {
cout << "茶叶";
} else {
cout << "其他";
}
{{ select(6) }}
丝绸茶叶其他茶叶其他
- 驿站需要统计 到 中所有偶数的个数。以下代码的输出是什么?
int count = 0;
for(int i = 1; i <= 100; i++) {
if(i % 2 == 0) count++;
}
{{ select(7) }}
- 商队循环运输货物,直到货物重量变为 。以下循环的输出是什么?
int weight = 10;
do {
cout << weight << " ";
weight -= 3;
}
{{ select(8) }}
10 7 4 110 7 4 1 -210 7 410 7 4 1 0
- 驿站需要找出数组中的最大货物重量。以下代码中, 的最终值是多少?
int arr[] = {45, 23, 67, 12, 89};
int max = arr[0];
for(int i = 1; i < 5; i++) {
if(arr[i] > max) max = arr[i];
}
{{ select(9) }}
- 以下哪个关键字用于在循环中跳过本次迭代?
{{ select(10) }}
breakexitcontinuereturn
- 商队需要跳过编号为 的驿站。以下代码的输出是什么?
for(int i = 1; i <= 5; i++) {
if(i == 3) continue;
cout << i << " ";
}
{{ select(11) }}
1 2 3 4 51 2 4 51 2 3 41 2 4 5 3
- 嵌套循环输出九九乘法表的一部分。以下代码外层循环执行多少次?
for(int i = 1; i <= 3; i++) {
for(int j = 1; j <= 4; j++) {
// 内层循环
}
}
{{ select(12) }}
- 次
- 次
- 次
- 次
- 驿站使用
break提前结束循环。以下代码的输出是什么?
for(int i = 1; i <= 10; i++) {
if(i == 5) break;
cout << i << " ";
}
{{ select(13) }}
1 2 3 41 2 3 4 51 2 3 4 5 6 7 8 9 101 2 3 4 0
- 商队使用逻辑运算符判断。以下表达式值为
true的是?
{{ select(14) }}
(3 > 5) && (2 < 4)(3 > 5) || (2 < 4)!(2 < 4)(3 > 5) && (2 > 4)
- 驿站需要处理特殊情况。以下代码的输出是什么?
int a = 10, b = 0;
if(b == 0) {
cout << "错误";
} else {
cout << a / b;
}
{{ select(15) }}
错误除零错误
- 商队计算货物数量翻倍。以下循环的输出是什么?
int n = 1;
while(n < 50) {
n = n * 2;
}
{{ select(16) }}
- 驿站使用
for循环计算阶乘。以下代码中, 的最终值是多少?
int factorial = 1;
for(int i = 1; i <= 5; i++) {
factorial *= i;
}
{{ select(17) }}
- 商队判断货物是否需要特殊处理。以下代码的输出是什么?
int weight = 150;
string result = (weight > 100) ? "特殊处理" : "普通处理";
cout << result;
{{ select(18) }}
特殊处理普通处理
- 驿站需要处理多级分类。以下哪个语句最适合处理多条件分支?
{{ select(19) }}
if-else语句switch语句while语句for语句
- 商队使用嵌套
if判断。以下代码的输出是什么?
int score = 75;
if(score >= 60) {
if(score >= 80) {
cout << "优秀";
} else {
cout << "及格";
}
} else {
cout << "不及格";
}
{{ select(20) }}
优秀及格不及格