我来帮你
/*输入两个正整数m和n,求其最大公约数和最小公倍数*/
/*根据数学上对最大公约数和最小公倍数的定义来考虑算法*/
main()
{int m,n,a,b,temp,answer1,answer2;
printf("please input two integer numbers:\n");
scanf("%d%d",&m,&n);
if(m<n)
{temp=m;m=n;n=temp;}
a=m;b=n;
while(b!=0)
{temp=a%b;
a=b;
b=temp;
}
answer1=a;
answer2=m*n/a;
printf("the greatest common divisor is %d\n",answer1);
printf("the lease common multiple is %d\n",answer2);
return 0;
}
运行后绝对正确。