埃氏筛法求素数
作者:互联网
#include<iostream>
#include<climits>
using namespace std;
int a[105]={0};
int main(){
for (int i=2; i*i<=100; i++){
if(a[i]==0) {
for (int j=i*i; j<=100; j+=i){
a[j]=1;
}
}
}
for (int i=2; i<=100; i++){
if(a[i]==0){
cout<<i<<" ";
}
}
return 0;
}
标签:std,main,埃氏,cout,筛法,int,素数,include 来源: https://www.cnblogs.com/dks0313/p/15748208.html