> 数学 >
develop a program to calculater the least common multiple of two numbers input from the keyboard
人气:251 ℃ 时间:2020-05-05 17:44:54
解答
#include<stdio.h>  
void main()   //辗转相除法求最大公约数,然后最小公倍数=a*b/最大公倍数 
{   
   int m, n, a, b, t, c;  
   printf("Input two integer numbers:\n");  
   scanf("%d%d", &a, &b);  
   m=a;   n=b;  
   while(b!=0)  /* 余数不为0,继续相除,直到余数为0 */   
   { c=a%b; 
   a=b;  
   b=c;}  
   

   printf("The least common multiple:%d\n", m*n/a);  
}
推荐
猜你喜欢
© 2025 79432.Com All Rights Reserved.
电脑版|手机版