返回列表 發帖
本帖最後由 吳承勳 於 2015-7-18 11:12 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.     int a = 0;
  7.     int b = 0;
  8.     int c = 0;
  9.     float d = 0;
  10.     cin >> a;
  11.     for(int i = 1;  i <= a; i++)
  12.     {
  13.         if (a % i == 0){
  14.             cout << i << " ";
  15.             b++;
  16.             c += i;
  17.         }
  18.     }
  19.     d = c / b;
  20.     cout << endl;
  21.     cout << "因數數量:" << b << endl;
  22.     cout << "因數總和:" << c << endl;
  23.     cout << "因數平均:" << d << endl;
  24.     system("pause");
  25.     return 0;
  26. }
複製代碼

TOP

返回列表