- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a=0;
- while(true)//條件強制通過
- {
- system("cls");//清除
- cout<<"請輸入一正整數:"<<endl;
- cin>>a;
-
- cout<<a<<"的因數有:";
-
- for(int b=1;b<=a;b++)
- {
- if(a%b == 0)
- {
- cout<<" "<<b;
- }
- }
- cout << endl;
- system("pause");
- }
- return 0;
- }
複製代碼 |