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

TOP

返回列表