谁会
查看原帖
谁会
550880
谁家小迷妹鸭楼主2021/9/11 22:14

补全下面的埃氏筛法的代码,求出从2到n中的质数数量。

#include <iostream>
#include <cmath>
using namespace std;
int n, b[10000005], ans;
int main() {
    cin >> n;
    for(int i=____1____; i<=____2____; i++) {
        if(b[i]==____3____) {
            for(int j=____4____; j<=____5____; j+=____6____)
                b[j] = 1;
        }
    }
    for(int i=____7____; i<=____8____; i++)
        if(b[i]==0)
            ans ___9____;
    cout << ans;
    return 0;
}
2021/9/11 22:14
加载中...