克痹骨泰片多少钱:c语言问题

来源:百度文库 编辑:高考问答 时间:2024/05/03 06:24:43
怎样判断2个数为最大公约数,最小公倍数

#include<stdio.h>
void main()
{
int p,r,n,m,temp;
printf("请输入两个整数n,m:\n");
scanf("%d%d",&n,&m);
if(n<m)
{
temp=n;
n=m;
m=temp;
}
p=n*m;
while (m!=0)
{
r=n%m;
n=m;
m=r;
}
printf("他们的最大公约数为:%d\n",n);
printf("他们的最小公倍数为:%d\n",p/n);
}