#622. 客观题模拟5
客观题模拟5
信阳市中小学人工智能教育创意大赛模拟试题(C++)
题目描述
本试卷共20道单项选择题,考察基本语法、逻辑结构和简单算法。
第1题
在计算机系统中,CPU的主要功能是什么?
{{ select(1) }}
- 存储数据
- 执行算术和逻辑运算
- 显示图像
- 连接网络
第2题
下列哪种存储器的访问速度最快?
{{ select(2) }}
- 硬盘
- U盘
- 内存
- 寄存器
第3题
在C++中,以下哪个是合法的变量名?
{{ select(3) }}
2varvar-name_varreturn
第4题
下列哪个运算符的优先级最高?
{{ select(4) }}
+=*==
第5题
在C++中,表达式 5 / 2 的结果是什么?
{{ select(5) }}
- 2.5
- 2
- 3
- 2.0
第6题
以下关于C++函数的描述,哪个是正确的?
{{ select(6) }}
- 函数必须有返回值
- 函数可以没有参数
- 函数名可以以数字开头
- 函数必须在main函数之前定义
第7题
在C++中,以下哪个关键字用于循环结构?
{{ select(7) }}
ifswitchforbreak
第8题
下列哪个数据类型通常占用内存最小?
{{ select(8) }}
intdoublecharfloat
第9题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int a = 5, b = 3;
a = a + b;
b = a - b;
a = a - b;
cout << a << " " << b;
return 0;
}
{{ select(9) }}
- 5 3
- 3 5
- 8 5
- 5 8
第10题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int sum = 0;
for (int i = 1; i <= 5; i++) {
if (i % 2 == 0) continue;
sum += i;
}
cout << sum;
return 0;
}
{{ select(10) }}
- 6
- 9
- 15
- 5
第11题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int func(int x) {
if (x <= 1) return 1;
return x * func(x - 1);
}
int main() {
cout << func(4);
return 0;
}
{{ select(11) }}
- 10
- 16
- 24
- 36
第12题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int arr[5] = {1, 2, 3, 4, 5};
int *p = arr;
cout << *(p + 2);
return 0;
}
{{ select(12) }}
- 1
- 2
- 3
- 4
第13题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int a = 10;
int &b = a;
b = 20;
cout << a;
return 0;
}
{{ select(13) }}
- 10
- 20
- 30
- 编译错误
第14题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int i = 1;
while (i < 10) {
i *= 2;
}
cout << i;
return 0;
}
{{ select(14) }}
- 8
- 10
- 16
- 32
第15题
阅读以下代码,输出结果是什么?
#include <iostream>
using namespace std;
int main() {
int x = 5;
if (x > 3) {
cout << "A";
} else if (x > 2) {
cout << "B";
} else {
cout << "C";
}
return 0;
}
{{ select(15) }}
- A
- B
- C
- AB
第16题
以下程序用于计算1到n的累加和,请选择正确的填空内容:
#include <iostream>
using namespace std;
int main() {
int n, sum = 0;
cin >> n;
for (int i = 1; i <= n; ______) {
sum += i;
}
cout << sum;
return 0;
}
{{ select(16) }}
i++i--i += 2i = i * 2
第17题
以下程序用于判断一个数是否为偶数,请选择正确的填空内容:
#include <iostream>
using namespace std;
int main() {
int num;
cin >> num;
if (______) {
cout << "偶数";
} else {
cout << "奇数";
}
return 0;
}
{{ select(17) }}
num % 2 == 1num / 2 == 0num % 2 == 0num * 2 == 0
第18题
以下程序用于找出三个数中的最大值,请选择正确的填空内容:
#include <iostream>
using namespace std;
int main() {
int a, b, c, max;
cin >> a >> b >> c;
max = a;
if (______) {
max = b;
}
if (c > max) {
max = c;
}
cout << max;
return 0;
}
{{ select(18) }}
b > ab < ab == ab != a
第19题
以下程序用于计算斐波那契数列的第n项,请选择正确的填空内容:
#include <iostream>
using namespace std;
int main() {
int n, a = 0, b = 1, c;
cin >> n;
if (n == 1) {
cout << a;
return 0;
}
for (int i = 3; i <= n; i++) {
c = a + b;
______;
b = c;
}
cout << b;
return 0;
}
{{ select(19) }}
a = ba = cb = aa = a + b
第20题
以下程序用于统计字符串中数字字符的个数,请选择正确的填空内容:
#include <iostream>
#include <string>
using namespace std;
int main() {
string s;
int count = 0;
cin >> s;
for (int i = 0; i < s.length(); i++) {
if (______) {
count++;
}
}
cout << count;
return 0;
}
{{ select(20) }}
s[i] >= '0' && s[i] <= '9's[i] >= 0 && s[i] <= 9s[i] >= "0" && s[i] <= "9"s[i] >= 'a' && s[i] <= 'z'
相关
在下列比赛中: