天天看点

最大公约数和最小公倍数

#include<stdio.h>

int main()

{

 int a,b,r,m,n;

 printf("Please input two numbers:");

 scanf("%d%d",&a,&b);

 m=a,n=b;

 while(b)

 {

  r=a%b;

  a=b;

  b=r;

 }

 printf("%d he %d de zui da gong yue shuo shi %d\n",m,n,a);

 printf("%d he %d de zui xiao gong bei shuo shi %d\n",m,n,m*n/a);

 //getch();

 return 0;

}

本文转自terryli51CTO博客,原文链接: http://blog.51cto.com/terryli/520867,如需转载请自行联系原作者

继续阅读