#include <iostream> #include <fstream>
using namespace std;
const int LENGTH=500;
bool Array[LENGTH]={false};
int main()
{
ofstream FILE("Result.txt",ios::app);
for (int i=2;i<=LENGTH;++i)
{
if (Array[i]==false)
{
cout<<i<<" ";
FILE<<i<<" ";
for (int j=i+i;j<=LENGTH;j+=i)//HERE!筛选法求素数!
{
Array[j]=true;
}
}
}
cout<<endl;
FILE<<endl;
FILE.close();
}
using namespace std;
const int LENGTH=500;
bool Array[LENGTH]={false};
int main()
{
ofstream FILE("Result.txt",ios::app);
for (int i=2;i<=LENGTH;++i)
{
if (Array[i]==false)
{
cout<<i<<" ";
FILE<<i<<" ";
for (int j=i+i;j<=LENGTH;j+=i)//HERE!筛选法求素数!
{
Array[j]=true;
}
}
}
cout<<endl;
FILE<<endl;
FILE.close();
}