返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {  
  6.   cout<<"10000以內的質數有:"<<endl;   
  7.   for(int i=2; i<=10000;i++)  
  8.   {
  9.    int z=0;
  10.    for(int y=2; y<=10000;y++)         
  11.    {
  12.     if(i%y==0)
  13.      {      
  14.       z++;   
  15.      }
  16.    }
  17.   if(z==1)
  18.   cout<< i <<endl;  
  19.   }
  20.     system("pause");
  21.     return 0;     
  22. }
複製代碼

TOP

返回列表