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