7-26 最大公约数和最小公倍数
1 #include <stdio.h> 2 3 int main(void) 4 { 5 int m, n; 6 int gcd, lcm; 7 scanf("%d %d", &m, &n); 8 int t1 = m; 9 int t2 = n; 10 11 int t; 12 if (m < n) 13 { 14 t = m; 15 m = n; 16 n = t; 17 } 18 19 while (n != 0) 20 { 21 t = m % n; 22 m = n; 23 n = t; 24 } 25 gcd = m; 26 lcm = t1 * t2 / gcd; 27 28 printf("%d %d\n", gcd, lcm); 29 30 return 0; 31 }