返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main ()
  4. {

  5.     int n;
  6.     cin >> n ;
  7.     for(int j=2;j<n;j++)
  8.     {
  9.         bool prime=true;
  10.         for(int i=2;i<=sqrt(j);i++)
  11.         {
  12.             if(j%i==0)
  13.             {
  14.                 prime=false;
  15.             }
  16.         }
  17.         if(prime)
  18.             cout<< j <<" ";
  19.     }



  20.     return 0;
  21. }
複製代碼

TOP

返回列表