返回列表 發帖
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a,sum=0;
  6.     cout<<"請輸入一個正整數:";
  7.     cin>>a;
  8.     cout<<a<<"的因數";
  9.     for (int i=1; i<=a; i++)
  10.     {
  11.         if(a%i==0)
  12.         {
  13.           cout<<i<<" ";
  14.           sum++;  
  15.         }
  16.     }
  17.     cout<<endl;
  18.     cout<<"總共有"<<sum<<"個因數"<<endl;   
  19.     system("pause");
  20.     return 0;
  21. }
複製代碼

TOP

返回列表