返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main ()
  5. {
  6.         int a, b, c;
  7.         float d;
  8.         cout<<"輸入一個正整數:";
  9.         cin>>a;
  10.         for (int i = 1; i<=a;i++)
  11.         {
  12.                 if (a % i == 0)
  13.                 {
  14.                         cout<< i<<" ";
  15.                         b++;
  16.                         c=c+i;
  17.                        
  18.                        
  19.                 }
  20.         }
  21.         d =(float)c/b;
  22.         cout<<"因數數量"<<b<<endl;
  23.         cout<<"因數總和"<<c<<endl;
  24.         cout<<"因數平均值"<<d<<endl;
  25.         system ("pause");
  26.         return 0;

  27. }
複製代碼

TOP

返回列表