#include<stdio.h>
int main()
{
int n1,n2,x,y,temp;
printf("请输入两个数用空格隔开:\n");
scanf("%d %d",&n1,&n2);
x=n1>n2?n1:n2;//保存较大数
y=n1+n2-x;
while (x!=0)
{
temp=y%x;
y=x;
x=temp;
}
printf("最大公约数:%d",y);
printf("最小公倍数:%d",n1*n2/y);
}
标签:temp,公倍数,C语言,最大公约数,printf,n1,n2 From: https://www.cnblogs.com/hyborn/p/17231338.html