客观模拟4
该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。
信阳市中小学人工智能教育创意大赛模拟试题(C++)
题目描述
本试卷共20道单项选择题,考察计算机基础知识、C++基本语法、程序阅读和理解能力。
第1题
在计算机中,CPU的主要功能是什么?
{{ select(1) }}
- 存储数据
- 控制计算机的所有操作
- 显示图像
- 连接网络
第2题
下列哪个设备属于计算机的输出设备?
{{ select(2) }}
- 键盘
- 鼠标
- 显示器
- 扫描仪
第3题
在C++中,下列哪个关键字用于定义一个整型变量?
{{ select(3) }}
floatdoubleintstring
第4题
以下哪个是合法的C++变量名?
{{ select(4) }}
2varmy-var_countfloat
第5题
在C++中,用于输出到控制台的关键字是?
{{ select(5) }}
printcoutprintfoutput
第6题
下列哪个运算符用于求余数?
{{ select(6) }}
+-*%
第7题
在C++中,bool类型的值可以是?
{{ select(7) }}
- 0和1
- true和false
- 1和2
- yes和no
第8题
以下哪个头文件用于输入输出操作?
{{ select(8) }}
<cmath><string><iostream><algorithm>
第9题
以下代码的输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 2;
cout << a / b;
return 0;
}
{{ select(9) }}
- 2
- 2.5
- 3
- 编译错误
第10题
以下代码的输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int x = 10;
if (x > 5) {
cout << "A";
} else {
cout << "B";
}
return 0;
}
{{ select(10) }}
- A
- B
- AB
- 编译错误
第11题
以下代码的输出结果是什么?
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 3; i++) {
cout << i;
}
return 0;
}
{{ select(11) }}
- 012
- 123
- 013
- 编译错误
第12题
以下代码的输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int i = 1;
while (i <= 3) {
cout << i;
i++;
}
return 0;
}
{{ select(12) }}
- 123
- 012
- 013
- 无限循环
第13题
以下代码的输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int arr[3] = {1, 2, 3};
cout << arr[1];
return 0;
}
{{ select(13) }}
- 1
- 2
- 3
- 0
第14题
请补全下面的代码,使其能够正确计算1+2+3+4+5的和:
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 1; i <= 5; i++) {
______ // 填空处
}
cout << sum;
return 0;
}
{{ select(14) }}
sum = i;sum += i;sum = sum + 1;i += sum;
第15题
请补全下面的代码,使其能够判断一个数是否为偶数:
#include <iostream>
using namespace std;
int main() {
int num = 8;
if (______) { // 填空处
cout << "偶数";
} else {
cout << "奇数";
}
return 0;
}
{{ select(15) }}
num % 2 == 0num % 2 == 1num / 2 == 0num / 2 == 1
第16题
请补全下面的代码,使其能够输出数组中的最大值:
#include <iostream>
using namespace std;
int main() {
int arr[5] = {3, 7, 2, 9, 1};
int max = arr[0];
for (int i = 1; i < 5; i++) {
if (______) { // 填空处
max = arr[i];
}
}
cout << max;
return 0;
}
{{ select(16) }}
arr[i] > maxarr[i] < maxarr[i] == maxarr[i] != max
第17题
请补全下面的代码,使其能够正确输出乘法表的一行:
#include <iostream>
using namespace std;
int main() {
int n = 5;
for (int i = 1; i <= n; i++) {
cout << ______ << " "; // 填空处
}
return 0;
}
{{ select(17) }}
n * in + in - in / i
第18题
请补全下面的代码,使其能够统计字符串中数字字符的个数:
#include <iostream>
#include <string>
using namespace std;
int main() {
string str = "abc123def456";
int count = 0;
for (int i = 0; i < str.length(); i++) {
if (______) { // 填空处
count++;
}
}
cout << count;
return 0;
}
{{ select(18) }}
str[i] >= '0' && str[i] <= '9'str[i] >= 'a' && str[i] <= 'z'str[i] >= 'A' && str[i] <= 'Z'str[i] == ' '
第19题
请补全下面的代码,使其能够交换两个变量的值:
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 10;
______ // 填空处
a = b;
b = temp;
cout << a << " " << b;
return 0;
}
{{ select(19) }}
int temp = a;int temp = b;temp = a;temp = b;
第20题
请补全下面的代码,使其能够计算阶乘:
#include <iostream>
using namespace std;
int main() {
int n = 5;
int result = 1;
for (int i = 1; i <= n; i++) {
______ // 填空处
}
cout << result;
return 0;
}
{{ select(20) }}
result *= i;result += i;result = i;result = n;