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

TOP

返回列表