解题思路:
1、用辗转相除法得出最大公约数
2、最小公倍数=两数相乘/最大公约数
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int a, b, c, d;
scanf("%d%*c%d", &a, &b);
c = a;
d = b;
while (c%d != 0) { // 用辗转相除法得出最大公约数
int t = c;
c = d;
d = t%d;
}
printf("%d %d\n", d, a*b/d);
return 0;
}
0.0分
0 人评分