标签:sam 最小 [] amp 输入 style 习题 max nbsp
5 7
1 35
1 #include <stdio.h> 2 3 int max_common_diviser(int n1, int n2) 4 { 5 int temp; 6 7 if(n1 < n2) 8 { 9 temp = n1; n1 = n2; n2 = temp; 10 } 11 12 13 while(n1 % n2 != 0) 14 { 15 int t = n2; 16 n2 = n1 % n2; 17 n1 = t; 18 } 19 20 return n2; 21 } 22 23 int min_common_multiple(int n1, int n2) 24 { 25 return n1 * n2 / max_common_diviser(n1, n2); 26 } 27 28 int main(int argc, char const *argv[]) 29 { 30 31 int m, n; 32 while(scanf("%d%d", &m, &n) != EOF) 33 { 34 printf("%d %d\n", max_common_diviser(m, n), min_common_multiple(m, n)); 35 } 36 37 return 0; 38 }
标签:sam 最小 [] amp 输入 style 习题 max nbsp
原文地址:http://www.cnblogs.com/hello-lijj/p/7827601.html