c语言中如何用辗转相除求最大公约数、求最小公倍数?

问题描述:

c语言中如何用辗转相除求最大公约数、求最小公倍数?

#include
void main()
{
int a,b,x,y,temp;
x = 34; y = 12;
if(x {
temp = x; x = y; y = temp;
}
a = x; b = y;
while(b != 0)
{
temp = a % b;
a = b;
b = temp;
}
printf("yue:%d\n",a);
printf("bei:%d\n",x*y / a);
}