Input two integers from the keyboard. the maximum and minimum public approx.
Method 1: Exhaustion
# Include <stdio. h>
Main ()
{
Int m, n, I;
Scanf ("% d", & m, & n );
For (I = m; I --)
If (m % I = 0 & n % I = 0) break;
Printf ("% d, % d", I, m * n/I );
}
---------------------------------------
# Include <stdio. h>
Main ()
{
Int m, n, t, I;
Scanf ("% d", & m, & n );
For (I = 1; I <= (m <n? M: n); I ++)
If (! (M % I )&&! (N % I) t = I;
Printf ("% d, % d", t, m * n/t );
}
Method 2: Moving Phase Division
# Include <stdio. h>
Main ()
{
Int m, n, t, r;
Scanf ("% d", & m, & n );
R = m * n;
T = m % n;
While (t)
{M = n; n = t; t = m % n ;}
Printf ("% d, % d", n, r/n );
}
Analysis:
40% 32 = 8;
32% 8 = 0;
Therefore, the maximum number of public appointments is 8.
Minimum Public multiple 40*32/8 = 160
Method 4: subtraction
# Include <stdio. h>
Main ()
{
Int m, n, r;
Scanf ("% d", & m, & n );
R = m * n;
While (m! = N)
If (m> n) m = m-n;
Else n = n-m;
Printf ("% d, % d", m, r/m );
}
Analysis:
40-32 = 8;
32-8 = 24;
24-8 = 16;
16-8 = 8;
8 = 8 = 0;
Due to my limited conditions, I only use other people's computers for simple analysis. If you do not understand it, please check the information on your own.
If any error occurs, please note