C语言计算2个数的最小公倍数

#include<stdio.h>
int main()
{
   int a,b,i=1,temp,lcm;
   scanf("%d %d",&a,&b);
   if(a>b)
   {
       temp=a;
       a=b;
       b=temp;
   }
  lcm=b;
   if(b%a!=0)
   {
    
       while(lcm%a!=0)
        {
        lcm=b*i;
        i++;
        }

       
   printf("%d",lcm);
   }
   else printf("%d",b);

}

posted @ 2016-12-24 11:41  legenda  阅读(6031)  评论(0编辑  收藏  举报