返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.     re:
  6.     int x,sum=0;
  7. cout<<"***天才兒童的質數製造機***"<<endl;
  8. cout<<"請輸入數字";
  9. cin>>x;
  10. for(int i=1;i<=x;i++)
  11. {
  12. if(x%i==0)
  13. sum++;
  14. }
  15. if(sum==2)
  16.     cout<<x<<"是質數"<<endl;
  17. else
  18. cout<<x<<"不是質數"<<endl;
  19. cout<<endl;
  20. goto re;



  21. system("pause");
  22. return 0;

  23. }
複製代碼

TOP

返回列表