//题目:输入两个正整数m和n,求其最大公约数和最小公倍数。
#include <stdio.h>
int main (void)
{
int m,n,temp,a,b;
printf("Please input two number :");
scanf("%d %d",&m,&n);
if(m<n)
{
temp=m;
m=n;
n=temp;
}
a=m;
b=n;
while(n!=0)
{
temp=m%n;
m=n;
n=temp;
}
printf("最大公约数为%d\n",m);
printf("最小公倍数为%d\n",a*b/m);
return 0;
}
/*
#include<stdio.h>
int main (void)
{
int a,b,num1,num2,temp;
printf("Please input two number :\n");
scanf("%d %d",&num1,&num2);
if(num1<num2)
{
temp=num1;
num1=num2;
num2=temp;
}
printf("%d %d\n",num1,num2);
a=num1;
b=num2;
while(b!=0)
{
temp=a%b;
a=b;
b=temp;
}
printf("gongyueshu:%d\n",a);
printf("gongbeishu:%d\n",num1*num2/a);
return 0;
} */