返回列表 發帖
本帖最後由 林宇翔 於 2014-4-5 13:56 編輯
  1. #include <iostream>
  2. #include <cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         int x;
  7.         int y;
  8.         y = 0;
  9.         cout << "請輸入一個數字;" ;
  10.         cin >> x;
  11.         cout << "這個數字的因數有";
  12.         for(int i = 1; i <= x; i ++)
  13.         {
  14.                 if (x % i == 0)
  15.                 {
  16.                 y++;
  17.                 }
  18.         }
  19.         cout << y << "個" ;
  20.         cout << endl;
  21.         system ("pause");
  22.         return 0;
  23. }
複製代碼

TOP

返回列表