测评会员优惠活动进行中 · 开通 VIP,有效期内测评不限次 VIP 优惠中 · 测评不限次 立即查看

A22427. #include <bits/stdc++.h> using namespace std; int main(){ int a = 0, b = 0, cnt = 0; cin >> a >> b; for(int n = a; n <= b; n++){ bool isPrime = true; for(int i = 2; i <= n-1; i++){ if(n % i == 0){ is…

判断题 较易

题目描述

#include <bits/stdc++.h>
using namespace std;
int main(){
    int a = 0, b = 0, cnt = 0;
    cin >> a >> b;
    for(int n = a; n <= b; n++){
        bool isPrime = true;
        for(int i = 2; i <= n-1; i++){
            if(n % i == 0){
                isPrime = false;
                break;
            }
        }
        if(isPrime){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}
假设输入的约定 (2≤a≤b≤100),完成下面的判断题和单选题。

代码中第1行语句改为#include,程序输出结果不变。(    )

选项(单选)

上一题 下一题