#include
//求两个数的最大公约数和最小公倍数
void fun(int a,int b)
{
int temp,r;
int v;
if(a {temp=a; a=b; b=temp;} //将大数放在a中,小数放在b
v=a*b;
r=a%b;
while(r!=0)
{
a=b;
b=r;
r=a%b;
}
v/=b;
printf("最大公约数为%d\n",b);
printf("最小公倍数为%d\n",v);
}
int main()
{
int a,b;
scanf("%d%d",&a,&b);
fun(a,b);
return 0;
}
#include
int main(void){
int m,n,t;
printf("Input m & n(int m,n>0)...\n");
if(scanf("%d%d",&m,&n)!=2 || m<1 || n<1){
printf("Input error, exit...\n");
return 0;
}
printf("The GCD of %d & %d is ",m,n);
while(t=m%n,m=n,n=t);
printf("%d\n",m);
return 0;
}