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

TOP

返回列表