#include<stdio.h>
#include<conio.h>
int commut(int a, int b)
{
int min = a;
if (a < b)
min = a;
else
min = b; //求两个数中较小者
int i;
int result = 0,j=0;
int ya=0, yb=0;
for (i = min; i >= 2; i--) //求最大公因数
{
ya = a % i;
yb = b % i;
if (ya == 0 & yb == 0)
{
j++; //j判断有无公因数
result = a * b / i;
break;
}
}
if (j == 0)
result = a * b;
return result;
}
int main()
{
int a, b, c, result_1,result_2;
printf("请输入三个数,并按空格隔开\n");
scanf_s("%d%d%d", &a,&b,&c);
result_1 = commut(a, b);
result_2 = commut(result_1, c);
printf("%d和%d的公倍数是%d\n", a, b, result_1);
printf("%d,%d,%d的公倍数是%d\n", a,b, c, result_2);
getch();
return 0;
}