返回列表 發帖
  1. #include<cstdlib>
  2. #include<iostream>
  3. using namespace std;
  4. int main(){
  5.     int a,b=0 ;
  6.     cout<< "輸入一個整數: ";
  7.     cin>>a;
  8.     for(int x=1;x<=a;x++){
  9.     if(a%x==0)
  10.     {
  11.     b++;
  12.               }        
  13.     }
  14.     if (b==2){
  15.     cout<<endl<<"是質數"<<endl;}
  16.     else{
  17.     cout<<endl<<"不是質數"<<endl;
  18.     }
  19.    
  20.     system("pause");
  21.    
  22.     return 0;
  23. }
複製代碼
Attention Seeker </3

TOP

返回列表