返回列表 發帖
  1. #include<iostream>
  2. using namespace std;
  3. int main()
  4. {
  5.     int x,y,count=0;

  6.     cout<<"請輸入第一個數:";
  7.     cin>>x;
  8.     cout<<"請輸入第二個數:";
  9.     cin>>y;
  10.     cout<<endl<<x<<"與"<<y<<"的最小公倍數是:";

  11.     for(int i=1;i<=x*y;i++)
  12.     {
  13.         if(i%x==0 && i%y==0)
  14.         {
  15.             cout<<i<<endl;
  16.             break;
  17.         }
  18.     }
  19. }
複製代碼

TOP

返回列表