for (int i = 2; i <= n; i++) {
if (!not_prime[i]) primes[++cnt] = i;
for (int j = 1; j <= cnt && i * primes[j] <= n; j++) {
not_prime[i * primes[j]] = true;
if (________) break; // 在此处填入选项
}
}
2分
登录后查看选项
11在C++语言中,关于类的继承和访问权限,下列说法正确的是( )。2分
登录后查看选项
12
当输入 6 时,下列程序的输出结果为( )。
#include <iostream>
using namespace std;
int f(int n) {
if (n <= 3) return n;
return f(n - 1) + f(n - 2) + 2 * f(n - 3);
}
int main() {
int n;
cin >> n;
cout << f(n) << endl;
return 0;
}
2分
登录后查看选项
13从1到999这999个正整数中,十进制表示中数字 5 恰好出现一次的数有多少个?2分
登录后查看选项
14
当输入 2023 时,下列程序的输出结果为( )。
#include <iostream>
using namespace std;
int main() {
int x, ans = 0;
cin >> x;
while (x != 0) {
x -= x & -x;
ans++;
}
cout << ans << endl;
return 0;
}