#include <iostream> using namespace std; int main() { int a = 0; cin >> a; int j =2; for(j=2;j<=a;j++) { if(j==a) { cout<<"是质数"<<endl; break; } if(a%j==0) { cout<<"不是质数"<<endl; break; } } return 0; }
#include <iostream> using namespace std; int main() { int a = 0; cin >> a; int j =2; for(j=2;j<=a;j++) { if(j==a) { cout<<"是质数"<<endl; break; } if(a%j==0) { cout<<"不是质数"<<endl; break; } } return 0; }