返回列表 發帖
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main(){
  4.     int a;
  5.     cin>>a;
  6.     bool Prime=true;
  7.     for(int j=2;j<a;j++){
  8.         for(int i=2;i<=sqrt(j);i++)
  9.         {
  10.             if(!(j%i))
  11.             Prime=false;
  12.         }
  13.         if(Prime)
  14.             cout<<j<<" ";
  15.         Prime=true;
  16.     }
  17. }
複製代碼

TOP

返回列表