- #include <iostream>
- #include <cstdlib>
- using namespace std;
- int main ()
- {
- int a, b ,c , d, i , max, gt, gf;
- cout << "輸入四個數字 :";
- cin >> a >> b>>c>>d;
- gt = ( a > b ) ? a : b;
- gf= ( gt > c ) ? gt : c;
- max=(gf>gt)?gt:gf;
- for( i = max; i <= a * b * c * d; i++)
- {
- if( i % a == 0 && i % b == 0 && i % c == 0 && i%d ==0)
- {
- cout << i;
- cout << endl;
- break;
-
- }
- }
- system ("pause");
- return 0;
- }
複製代碼 |