Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. int i,j=2;
  6. cout << "請輸入要判斷的數字";
  7. cin >> i;
  8. if(i>=2)
  9. {do{j++;
  10. bool ck=0;
  11. if (i%j==0)
  12. {ck=1;
  13. }
  14. if (ck==0)
  15. {
  16. cout << "是質數" <<endl;
  17. }
  18. }
  19.  
  20. while(j<i);}
  21. else
  22. {cout << "是質數" <<endl;
  23. }
  24. system("pause");
  25. return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement