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