#include <stdio.h>
int main(int argc, const char * argv[]) {
int r,p,m=0,n=0;
printf("请输入2个正整数m和n\n");
scanf("%d%d",&m,&n);
if (m>n) {
int temp;
temp=m;m=n;n=temp;
}
p=m*n;
while (m!=0) {
r=n%m;n=m;m=r;
}
printf("最大公约数为%d\n",n );
printf("最小公倍数为%d\n",p/n );
return 0;
}
|
|