3. 题目:编一C程序,它能读入两个整数m与n,计算并输出m与n的绝对值的最大公约数及最小公倍数。(注:可执行文件名为e3_3.exe)
程序设计:
main()
{int m,n,d,r;
printf("Please enter m and n:\n");
scanf("%d %d",&m,&n);
if (m<0) m=-m;
if (n<0) n=-n;
if (m<n)
{r=m;m=n;n=r;}
d=m;
while (d%n!=0)
d+=m;
printf("%d\n",d);
do {r=m%n;
if (r!=0)
{m=n;n=r;}
}
while (r!=0);
printf("%d\n",n);
}