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

TOP

返回列表