📝 ### 第16题 **阅读程序(一)**(下列程序供第 16~20 题使用;判断题正确填 √,错误填 ×) ```cpp 01 #include <iostream> 02 using namespace std; 03 04 bool isPrime(int n) …
📂 C++
· ⚡ 难度 5
· ❓ 判断题
· 📖 CSP-J 第一轮考前模拟题(2026 年版)
### 第16题
**阅读程序(一)**(下列程序供第 16~20 题使用;判断题正确填 √,错误填 ×)
```cpp
01 #include <iostream>
02 using namespace std;
03
04 bool isPrime(int n) {
05 if (n <= 1) return false;
06 for (int i = 2; i * i <= n; i++) {
07 if (n % i == 0) return false;
08 }
09 return true;
10 }
11
12 int main() {
13 int n, cnt = 0, sum = 0;
14 cin >> n;
15 for (int i = 2; i <= n; i++) {
16 if (isPrime(i)) {
17 cnt++;
18 sum += i;
19 }
20 }
21 cout << cnt << " " << sum << endl;
22 return 0;
23 }
```
**判断题**:该程序的功能是统计 2 到 n 之间素数的个数与和。( )