#include<iostream>
#include<ctime>
using namespace std;
int main()
{
clock_t start,finish;
start=clock();
int temp;
int i,j,k,p=0;
bool a[100001];
/*int b[30000];*/
for( i=0;2*i+3<=10000;i++)
a[i]=true;
for(j=0;j<i;j++)
{
if(a[j])
{
cout<<2*j+3<<endl;
for(k=j*(2*j+6)+3;k<i;k+=(2*j+3))
a[k]=false;
}
}
finish=clock();
cout<<(double)(finish-start)/CLOCKS_PER_SEC;
/* for(int s=0;s<p;s++)
cout<<b[s]<<endl;*/
return 0;
}
求素数的问题,数组开的够大啊,可是运行会爆掉,怎么回事啊
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-