代码:
#include
void common_multiple(a,b,c)
int a,b,c;
{
if(a>0 && b>0 && c>0)
{
if(a%(b*c)==0)
{
printf("Least common mutiple is %d",a);
return;
}
if(b%(a*c)==0)
{
printf("Least common mutiple is %d",b);
return;
}
if(c%(a*b)==0)
{
printf("Least common mutiple is %d",c);
return;
}
int i;
for(i=a*b;i<=a*b*c;i+=a*b)
{
if(i%c==0)
{
printf("Least common mutiple is %d",i);
return;
}
}
}
else
puts("no least common mutiple");
}
int main()
{
int a=1,b=2,c=3;
puts("please input three positive integer: ");
scanf("%u,%u,%u",&a,&b,&c);
common_multiple(a,b,c);
return 0;
}
运行
文章评论(0条评论)
登录后参与讨论