#sy0011. 2026算法应用 丝路新程 C++ 模拟题2
2026算法应用 丝路新程 C++ 模拟题2
单选题(15题,共75分)
第1题(5分)
在 C++ 中,想要在屏幕上输出“丝路驼队出发!”,应该使用以下哪条语句?
{{ select(1) }}
cout << "丝路驼队出发!";cin >> "丝路驼队出发!";print("丝路驼队出发!");printf("丝路驼队出发!")
第2题(5分)
已知变量 silk 表示丝绸匹数,瓷器数量比丝绸多 8 件。以下哪行代码可以正确计算瓷器数量并存入变量 china?
{{ select(2) }}
china = silk + 8;china == silk + 8;silk + 8 = china;china = silk - 8;
第3题(5分)
商队有骆驼 15 头,每头载重 180 千克。以下哪段代码能正确计算总载重并存入变量 total?
{{ select(3) }}
total = 15 * 180;total = "15" * 180;total = 15 + 180;total = 15 / 180;
第4题(5分)
下列哪个变量名符合 C++ 命名规则?
{{ select(4) }}
- 1_camel
- camel-count
- camel_count
- camel count
第5题(5分)
已有 int tea = 20; 执行 tea = tea + 10; 后,tea 的值是多少?
{{ select(5) }}
- 10
- 20
- 30
- 40
第6题(5分)
阅读以下代码,程序运行后会输出什么?
#include <iostream>
using namespace std;
int main() {
string item = "丝绸";
cout << "商队运送的商品是:" << item << endl;
return 0;
}
{{ select(6) }}
- 商队运送的商品是:
- 商队运送的商品是:丝绸
- 商队运送的商品是:"丝绸"
- 编译报错
第7题(5分)
如果要从键盘输入一个整数表示骆驼数量,并存入变量 camel,应使用以下哪条语句?
{{ select(7) }}
cin >> camel;cout << camel;cin << camel;cout >> camel;
第8题(5分)
下列哪个运算符用于判断两个数是否相等?
{{ select(8) }}
===!=>=
第9题(5分)
阅读以下程序,如果用户输入数字 2,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int choice;
cout << "请选择:1.陆上丝路 2.海上丝路 3.草原丝路" << endl;
cin >> choice;
if (choice == 1) {
cout << "您选择了陆上丝路" << endl;
} else if (choice == 2) {
cout << "您选择了海上丝路" << endl;
} else {
cout << "您选择了草原丝路" << endl;
}
return 0;
}
{{ select(9) }}
- 您选择了陆上丝路
- 您选择了海上丝路
- 您选择了草原丝路
- 程序报错
第10题(5分)
在 C++ 中,循环 for(int i = 0; i < 5; i++) 的循环体将执行多少次?
{{ select(10) }}
- 4 次
- 5 次
- 6 次
- 不确定
第11题(5分)
要计算“驼队行走 7 天的总里程”,已知每天走 40 里,且使用循环累加,以下哪种写法正确?
{{ select(11) }}
-
int total = 0; for(int i = 0; i < 7; i++) { total = total + 40; } -
int total = 0; for(int i = 0; i < 7; i++) { total = 40; } -
int total = 0; while(total < 7) { total = total + 40; } -
int total = 0; for(int i = 0; i <= 7; i++) { total = total + 40; }
第12题(5分)
以下代码横线处填入哪个选项,能正确输出数组内容?
#include <iostream>
using namespace std;
int main() {
string goods[3] = {"丝绸", "瓷器", "茶叶"};
cout << "商品列表:";
for(int i = 0; i < 3; i++) {
cout << ______ << " ";
}
return 0;
}
{{ select(12) }}
goodsgoods[i]goods[3]"goods"
第13题(5分)
阅读以下程序,它的功能是什么?
#include <iostream>
using namespace std;
int main() {
int weight;
cout << "请输入货物重量(斤):";
cin >> weight;
if (weight > 200) {
cout << "需要多头骆驼" << endl;
} else {
cout << "一头骆驼即可" << endl;
}
return 0;
}
{{ select(13) }}
- 计算需要多少头骆驼
- 判断货物是否超出一头骆驼的载重
- 计算货物总价值
- 输出货物种类
第14题(5分)
以下代码运行后,变量 result 的值是多少?
int silk = 12;
int china = 5;
int tea = 8;
int result = silk + china * 2 - tea;
{{ select(14) }}
- 14
- 19
- 22
- 26
第15题(5分)
在 C++ 中,如果要存储多个相同类型的数据(如多个商品名称),通常使用以下哪种数据类型?
{{ select(15) }}
- int
- string
- 数组
- bool
判断题(5题,共25分)
第1题(5分)
C++ 中,单行注释使用 //,多行注释使用 /* */。
{{ select(16) }}
- 正确
- 错误
第2题(5分)
语句 cout << 3 + 5 * 2; 的输出结果是 16。
{{ select(17) }}
- 正确
- 错误
第3题(5分)
可以使用 sizeof() 运算符获取数组占用的内存字节数。
{{ select(18) }}
- 正确
- 错误
第4题(5分)
循环 for(int i = 1; i <= 3; i++) 的循环体将执行 2 次。
{{ select(19) }}
- 正确
- 错误
第5题(5分)
条件语句中,else 可以单独使用,不必跟在 if 后面。
{{ select(20) }}
- 正确
- 错误