其他分享
首页 > 其他分享> > 输入两个正整数m和n,求其最大公约数和最小公倍数。

输入两个正整数m和n,求其最大公约数和最小公倍数。

作者:互联网

#include"stdio.h"
void main()
{ int a,b,t,r,n;
printf(“please input the a and b:\n”); scanf("%d%d",&a,&b);
if(a<b)
{ t=b; b=a; a=t;
}
r=a%b; n=a*b;
while(r!=0)
{ a=b; b=r; r=a%b;
}
printf(“这两个数的最大公约数为%d,最小公倍数为%d\n”,b,n/b);}

标签:a%,公倍数,最小,while,最大公约数,printf,求其
来源: https://blog.csdn.net/m0_54605301/article/details/113915572