返回列表 發帖
  1. #include <iostream>
  2. #include <cstdlib>

  3. using namespace std;
  4. int main()
  5. {
  6.         int j;
  7.     int h;
  8.     cout << "請輸入一個數字";
  9.         cin >> h;
  10.         cout << "請輸入二個數字";
  11.         cin >> j;
  12.     cout << "他們的公因數有:";
  13.     int l;
  14.     l = (h < j)? h : j;
  15.     for (int m = 1; m <= l; m++)
  16.     {
  17.             if (h % m == 0 && j % m == 0)
  18.             {
  19.                 cout << m << "  ";
  20.             }
  21.     }
  22.         system("pause");
  23.         return 0;
  24. }
複製代碼

TOP

返回列表