#include <iostream>#include <cmath>using namespace std;int main(){ int i,j; cin>>i; bool ch;? for(j=2;j<=sqrt(i);j++) { if(i%j==0) ch=true; ? //真 不是素?cái)?shù)? if(i%j!=0) ch=false; } if(ch) ? /*******/ cout<<"不是素?cái)?shù)"<<endl; else cout<<"是素?cái)?shù)"<<endl; }在/***/處,若改為if(ch=true)不能正常輸出,但是if(ch==false)可以正常輸出,為什么????
c++素?cái)?shù)問題
the__sky123
2017-12-29 11:44:50