返回列表 發帖
本帖最後由 吳承勳 於 2015-8-1 11:31 編輯
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {
  6.         while(true)
  7.         {
  8.         int A;
  9.         int B;
  10.         cout << "請輸入兩個數字:";
  11.         cin >> A >> B;
  12.         int Max = (A > B)? A : B;
  13.         for(int i = Max; true; i++)
  14.         {
  15.                 if(i % A == 0 && i % B == 0)
  16.                 {
  17.                         cout << i;
  18.                         break;
  19.                 }
  20.         }
  21.         system("pause");       
  22.         }
  23. return 0;
  24. }
複製代碼

TOP

返回列表