#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();
}
posted on 2008-02-28 23:17  悠然小调  阅读(280)  评论(0编辑  收藏  举报