Posted on 2007-07-01 01:03
停留的风 阅读(709)
评论(0) 编辑 收藏 所属分类:
C语言学习历程
#include <stdio.h>
int gcd(int u,int v)
{
int temp;
while(v!=0)
{
temp=u%v;
u=v;
v=temp;
}
return u;
}
void qiuJie(int a,int b)
{
int result=1;
result=a*b/gcd(a,b);
printf("The lcm of %i and %i is %i.\n",a,b,result);
}
int main(void)
{
int num1,num2;
printf("Enter two numbers !\n");
scanf("%i",&num1);
scanf("%i",&num2);
qiuJie(num1,num2);
return 0;
}
测试图: