返回列表 發帖
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int a, b,c, max, minf;
  6.     cout<<"請輸入第一個數: ";
  7.     cin>>a;
  8.     cout<<"請輸入第二個數: ";
  9.     cin>>b;
  10.     max=(a>b)?a:b;
  11.     c=a*b;
  12.     cout<<a<<"與"<<b<<"的最小公倍數為: ";
  13.     for(int i=max; i<=c; i++)
  14.     {
  15.          if(i%a==0 && i%b==0)
  16.          {
  17.              minf=i;
  18.              break;
  19.          }
  20.     }
  21.     cout<<minf<<endl;
  22.     system("pause");
  23.     return 0;   
  24. }
複製代碼

TOP

返回列表