本帖最後由 吳承勳 於 2015-7-18 11:12 編輯
- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a = 0;
- int b = 0;
- int c = 0;
- float d = 0;
- cin >> a;
- for(int i = 1; i <= a; i++)
- {
- if (a % i == 0){
- cout << i << " ";
- b++;
- c += i;
- }
- }
- d = c / b;
- cout << endl;
- cout << "因數數量:" << b << endl;
- cout << "因數總和:" << c << endl;
- cout << "因數平均:" << d << endl;
- system("pause");
- return 0;
- }
複製代碼 |