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