#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { cout<<2<<endl; int i,j,k,flag; i=3; while(i<=100) { j=2; k=sqrt(i); flag=1; while(j<=k) { if(i%j==0) { flag=0; break; } j++; } if(flag) cout<<i<<endl; i++; } return 0; }
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { cout<<2<<endl<<3<<endl; int i,j,k,flag; for(i=2;i<=100;i++) { k=sqrt(i); for(j=2;j<=k;j++) { if(i%j==0) { flag=0; break; } flag=1; } if(flag) { cout<<i<<endl; } } return 0; }
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { cout<<2<<endl; int i,j,k,flag; i=3; do { flag=1; k=sqrt(i); j=2; do { if(i%j==0) { flag=0; break; } j++; }while(j<=k); if(flag) cout<<i<<endl; i++; }while(i<=100); return 0; }
标签:std,include,cout,4.17,int,namespace,打卡,main From: https://www.cnblogs.com/Sunyiran/p/17323509.html