#include <stdio.h>
int main(void)
{
int a,b,r,m;
printf("请输入两个正整数:");
scanf("%d %d",&a,&b);
if(a < b){
a = a^b;
b = a^b;
a = a^b;
}
r = a%b;
m = a*b;
while(r != 0){
a = b;
b = r;
r = a%b;
}
printf("最大公约数为%d,最小公倍数为%d\r\n",b,m/b);
return 0;
}
输入两个正整数,求其最大公约数和最小公倍数
最新推荐文章于 2022-12-26 23:21:46 发布