- #include<iostream>
- #include<cstdlib>
- using namespace std;
- int main()
- {
- int a, b, c, d, e, bigger;
- cout<<"請輸入第一個數: ";
- cin>>a;
- cout<<"請輸入第二個數: ";
- cin>>b;
- cout<<"請輸入第三個數: ";
- cin>>c;
- d=(a>b)?a:b;
- bigger=(d>c)?d:c;
- for(int i=bigger; i<=a*b*c; i++)
- {
- if(i%a==0 && i%b==0 && i%c==0)
- {
- cout<<"兩數的最小公倍數為: "<<i<<endl;
- break;
- }
- }
- system("pause");
- return 0;
- }
複製代碼 |