您的位置:首页 > 其它

求两个整数的最大公约数和最小公倍数

2010-08-08 20:53 274 查看
#include <stdio.h>

int main(void){
int m,n,r;
int product=0;
int tmp;

printf("Please input two numbers:/n");
scanf("%d %d",&m,&n);

product=m*n;

if(m<n){
tmp=m;
m=n;
n=tmp;
}

r=m%n;
while(r!=0){
m=n;
n=r;
r=m%n;
}
printf("The maximal common divisor: %d/n",n);
printf("The minimal common multiple: %d/n",product/n);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: