#sy0014. 2026算法应用 丝路新程 C++ 模拟题3

2026算法应用 丝路新程 C++ 模拟题3

单选题(15题,共75分)

第1题(5分)
在 C++ 中,要输出丝路欢迎语“驼铃声声丝路远”,应使用以下哪条语句?

{{ select(1) }}

  • cout << "驼铃声声丝路远";
  • cin >> "驼铃声声丝路远";
  • print("驼铃声声丝路远");
  • printf("驼铃声声丝路远")

第2题(5分)
已知变量 silk 表示丝绸匹数,瓷器数量比丝绸多 12 件。以下哪行代码可以正确计算瓷器数量并存入变量 china?

{{ select(2) }}

  • china = silk + 12;
  • china == silk + 12;
  • silk + 12 = china;
  • china = silk - 12;

第3题(5分)
驼队从长安出发,每日行进 40 里,行走 x 天,以下哪段代码能正确计算总里程并存入变量 distance?

{{ select(3) }}

  • distance = 40 * x;
  • distance = "40" * x;
  • distance = 40 + x;
  • distance = 40 / x;

第4题(5分)
下列哪个变量名符合 C++ 命名规则?

{{ select(4) }}

  • 2_camel
  • camel-load
  • camel_load
  • camel load

第5题(5分)
已有 int tea = 200;(茶叶数量),执行 tea = tea - 30; 后,tea 的值是多少?

{{ select(5) }}

  • 30
  • 170
  • 200
  • 230

第6题(5分)
阅读以下代码,程序运行后会输出什么?

#include <iostream>
using namespace std;
int main() {
  string goods = "瓷器";
  cout << "商队运送的货物是:" << goods << endl;
  return 0;
}

{{ select(6) }}

  • 商队运送的货物是:
  • 商队运送的货物是:瓷器
  • 商队运送的货物是:"瓷器"
  • 编译报错

第7题(5分)
若要从键盘输入一个浮点数表示丝绸重量(斤),并存入变量 weight,应使用以下哪条语句?

{{ select(7) }}

  • cin >> weight;
  • cout << weight;
  • cin << weight;
  • cout >> weight;

第8题(5分)
下列哪个运算符用于判断两个数是否不相等?

{{ select(8) }}

  • =
  • ==
  • !=
  • >=

第9题(5分)
阅读以下程序,如果用户输入数字 3,输出结果是什么?

#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 < 8; i++) 的循环体将执行多少次?

{{ select(10) }}

  • 7 次
  • 8 次
  • 9 次
  • 不确定

第11题(5分)
以下代码横线处填入哪个选项,能够输出数组中的所有丝路城市?

#include <iostream>
using namespace std;
int main() {
  string cities[4] = {"长安", "敦煌", "喀什", "撒马尔罕"};
  for(int i = 0; i < 4; i++) {
    cout << ______ << " ";
  }
  return 0;
}

{{ select(11) }}

  • cities
  • cities[i]
  • cities[4]
  • "cities"

第12题(5分)
以下哪种排序算法的最坏时间复杂度为 O(n²)?

{{ select(12) }}

  • 快速排序(平均情况)
  • 选择排序
  • 归并排序
  • 堆排序

第13题(5分)
阅读以下程序,它的功能是什么?

#include <iostream>
using namespace std;
int main() {
  int n, sum = 0;
  cout << "输入骆驼数量:";
  cin >> n;
  for(int i = 1; i <= n; i++) {
    sum += 200;
  }
  cout << "总载重:" << sum << "斤" << endl;
  return 0;
}

{{ select(13) }}

  • 计算每头骆驼载重 200 斤时,n 头骆驼的总载重
  • 计算平均每头骆驼的载重
  • 输出骆驼数量
  • 计算最大载重量

第14题(5分)
以下代码运行后,变量 result 的值是多少?

int silk = 15;
int china = 4;
int tea = 10;
int result = silk + china * 3 - tea;

{{ select(14) }}

  • 17
  • 27
  • 37
  • 47

第15题(5分)
在 C++ 中,若要使用 sort 函数对一个数组进行排序,需要包含以下哪个头文件?

{{ select(15) }}

  • #include <iostream>
  • #include <cmath>
  • #include <algorithm>
  • #include <string>

判断题(5题,共25分)

第1题(5分)
C++ 中,单行注释可以使用 //,多行注释可以使用 /* */

{{ select(16) }}

  • 正确
  • 错误

第2题(5分)
语句 cout << 8 + 4 * 3; 的输出结果是 36。

{{ select(17) }}

  • 正确
  • 错误

第3题(5分)
数组在 C++ 中的下标从 0 开始。

{{ select(18) }}

  • 正确
  • 错误

第4题(5分)
continue 语句用于终止整个循环,跳出循环体。

{{ select(19) }}

  • 正确
  • 错误

第5题(5分)
贪心算法在求解最优化问题时,总是从局部最优出发,希望能得到全局最优解。

{{ select(20) }}

  • 正确
  • 错误