展开全部
//利用辗除法,求最大公约数和最小公倍数
#include <stdio.h>
void main()
{
int a, b, x, y, temp;
x = 34; y = 12;
if(x < y)
{
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);
}
#include <stdio.h>
void main()
{
int a, b, x, y, temp;
x = 34; y = 12;
if(x < y)
{
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);
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询