Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int main()
- {
- int i,j=2;
- cout << "請輸入要判斷的數字";
- cin >> i;
- if(i>=2)
- {do{j++;
- bool ck=0;
- if (i%j==0)
- {ck=1;
- }
- if (ck==0)
- {
- cout << "是質數" <<endl;
- }
- }
- while(j<i);}
- else
- {cout << "是質數" <<endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement