解题思路:
先求最大公约数,再利用最小公倍数等于两数的乘积除以最大公约数;
注意事项:
参考代码:
#include<stdio.h>
int main()
{
int a,b,temp,r,mul;
scanf("%d%d",&a,&b);
if(a<b)
{
temp=a;
a=b;
b=temp;
}
mul=a*b;
do
{
r=a%b;
a=b;
b=r;
}while(r!=0);
printf("%d\n",a);
printf("%d",mul/a);
return 0;
}
0.0分
0 人评分