中小学人工智能教育创意大赛
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
信阳市中小学人工智能教育创意大赛模拟试题(C++)
题目描述
本试卷共20道单项选择题,考察基本语法、逻辑结构和简单算法。
第1题
在C++中,下列哪个关键字用于定义一个整型变量?
{{ select(1) }}
floatdoubleintstring
第2题
在C++平台上提交代码时,主函数的正确定义方式是?
{{ select(2) }}
main()int Main()void main()int main()
第3题
下列哪个运算符的优先级最高?
{{ select(3) }}
=+*>
第4题
在C++中,语句 cout << "XinYang" << endl; 的作用是?
{{ select(4) }}
- 从键盘读取一个字符串"XinYang"
- 在屏幕上输出字符串"XinYang"并换行
- 定义一个名为XinYang的变量
- 比较变量是否等于"XinYang"
第5题
想要使用C++的标准输入输出流,程序开头需要包含哪个头文件?
{{ select(5) }}
<cstdio><iostream><cmath><string>
第6题
下列哪个是合法的C++变量名?
{{ select(6) }}
2nd_placemy-scoretotalCountfloat
第7题
表达式 (10 % 4) 的结果是?
{{ select(7) }}
- 2
- 2.5
- 3
- 0
第8题
在C++的题目中,如果要求输出"YES"或"NO",通常应该使用哪个控制结构?
{{ select(8) }}
- 顺序结构
- 循环结构
- 分支结构
- 函数结构
第9题
阅读以下程序段,如果输入 5 3,程序的输出是什么?
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (a > b) {
cout << "A ";
} else if (a == b) {
cout << "Equal ";
} else {
cout << "B ";
}
cout << "Finish";
return 0;
}
{{ select(9) }}
AA FinishB FinishEqual Finish
第10题
阅读以下程序段,如果输入 4 4,程序的输出是什么?
#include <iostream>
using namespace std;
int main() {
int a, b;
cin >> a >> b;
if (a > b) {
cout << "A ";
} else if (a == b) {
cout << "Equal ";
} else {
cout << "B ";
}
cout << "Finish";
return 0;
}
{{ select(10) }}
AA FinishB FinishEqual Finish
第11题
阅读以下程序段,输出的结果是多少?
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 1; i <= 5; i++) {
sum = sum + i;
}
cout << sum;
return 0;
}
{{ select(11) }}
- 10
- 15
- 20
- 25
第12题
如果将以下程序段中的循环条件改为 i < 5,输出的结果会是多少?
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 1; i <= 5; i++) {
sum = sum + i;
}
cout << sum;
return 0;
}
{{ select(12) }}
- 10
- 15
- 20
- 25
第13题
阅读以下程序段,输出的结果是多少?
#include <iostream>
using namespace std;
int main() {
int n = 10;
int count = 0;
while (n > 0) {
n = n - 2;
count++;
}
cout << count;
return 0;
}
{{ select(13) }}
- 4
- 5
- 6
- 10
第14题
阅读以下程序段,变量 n 在循环结束后,最终的值是多少?
#include <iostream>
using namespace std;
int main() {
int n = 10;
int count = 0;
while (n > 0) {
n = n - 2;
count++;
}
cout << count;
return 0;
}
{{ select(14) }}
- 0
- -2
- 1
- 2
第15题
阅读以下程序段,输出的结果是什么?
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = 3;
int z = (x++) * (--y);
cout << z << " " << x << " " << y;
return 0;
}
{{ select(15) }}
15 5 315 6 210 6 210 5 2
第16题
在C++的一道题目中,需要判断一个整数 year 是否为闰年。闰年的规则是:能被4整除但不能被100整除,或者能被400整除。下列哪个条件表达式是正确的?
{{ select(16) }}
if (year % 4 == 0)if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)if (year % 400 == 0)if (year % 4 == 0 || year % 100 != 0)
第17题
小杨想用程序计算1到100之间所有偶数的和。下面哪段代码可以正确实现这个功能?
{{ select(17) }}
- int sum = 0; for (int i = 1; i <= 100; i++) { sum += i; }
- int sum = 0; for (int i = 2; i <= 100; i++) { sum += i; }
- int sum = 0; for (int i = 2; i <= 100; i += 2) { sum += i; }
- int sum = 0; for (int i = 1; i <= 100; i += 2) { sum += i; }
第18题
以下代码段的目的是不断读取整数,直到读入的数字是0为止。划线处应填入什么?
int num;
do {
cin >> num;
// ... 其他处理 ...
} ________ ;
{{ select(18) }}
while (num == 0)while (num != 0)for (num != 0)if (num != 0)
第19题
在C++平台上解决一个"比较大小"的问题时,以下哪种思路是最直接和正确的?
{{ select(19) }}
- 使用循环生成所有可能的数字组合。
- 使用多个
if-else语句来比较输入的两个或三个数字。 - 使用数组存储所有数字,然后进行排序。
- 使用递归函数来分解问题。
第20题
以下关于C++中break语句的说法,哪个是正确的?
{{ select(20) }}
break只能用在switch语句中break只能用在循环语句中break可以立即终止整个程序break可以立即终止当前所在的循环或switch语句