返回列表 發帖
  1. #include<iostream>
  2. #include<cstdlib>
  3. using namespace std;
  4. int main()
  5. {

  6.     int a,b,c,d;
  7.     cout<<"輸入第一個數"<<endl;
  8.     cin>>a;
  9.     cout<<"輸入第二個數"<<endl;
  10.     cin>>b;
  11.     c=a<b?a:b;
  12.     for(int i=c;i>=1;i++){
  13.         if(i%a==0 && i%b==0){
  14.             d=i;
  15.             break;}}
  16.     cout<<"兩數的最小公倍數為"<<d<<endl;

  17.     system("pause");
  18.     return 0;
  19. }
複製代碼

TOP

返回列表