解题思路:素数慢慢判断
注意事项:
参考代码:
#include<bits/stdc++.h> using namespace std; int main() { int a; cin>>a; for(int i=2;i<=a;i++) { bool flag=true; for(int j=2;j<i;j++) { if(i%j==0) { flag=false; break; } } if(flag==true) cout<<i<<endl; } return 0; }
0.0分
2 人评分