问题:输入两个整数。系统自动输出两个数的最小公倍数
#include <stdio.h>
int Lcm(int a,int b)
{
int temp;
if(a<b)
{
temp=a;
a=b;
b=temp;
}
int product=a*b;
while(b!=0) //求出最大公约数存储在a中
{
int c=a%b;
a=b;
b=c;
}
int leastCommonMultiple=product/a; //最小公倍数
return leastCommonMultiple;
}
int main ()
{
int a,b;
printf("请输入两个整数\n");
scanf("%d%d",&a,&b);
int getLcm=Lcm(a,b);
printf("%d",getLcm);
return 0;
}