返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main(){
  5.     int a,b,tmp;
  6.     cout<<"請輸入兩數"<<endl;
  7.     cin>>a>>b;
  8.     cout<<a<<" "<<b<<"的最小公倍數為: ";
  9.     for(int i=a;i<=a*b;i++){
  10.         if(i%a==0 && i%b==0){
  11.             tmp=i;
  12.             break;
  13.         }
  14.     }
  15.     cout<<tmp<<endl;
  16.     system("pause");
  17.     return 0;

  18. }
複製代碼

TOP

返回列表