现在的位置: 首页 > 综合 > 正文

求两个数的最小公倍数

2013年03月02日 ⁄ 综合 ⁄ 共 288字 ⁄ 字号 评论关闭
#include <stdio.h>
#include 
<conio.h>

int divisor(int a,int b)
{
 
int r;
 
while ((r=a%b)!=0)
   
{a=b;b=r;}
 
return b;
}


int multiple(int a,int b)
{
 
int d;
 d
=divisor(a,b);
 
return a*b/d;
}


void main()
{
 
int a,b,c;
 clrscr();
 printf(
"Input a b:");
 scanf(
"%d,%d",&a,&b);
 c
=multiple(a,b);
 printf(
"c=%d",c);
}

抱歉!评论已关闭.