以下是引用–★–在2006-6-4 8:44:00的发言:
long lcm(int a,int b); //最小公倍数函数原型
您所求=lcm(lcm(m,n),lcm(x,y));
#include<stdio.h>
long gcd(long a,long b)
{
return b?gcd(b,a%b):a;
}
long lcm(long a,long b)//求小公倍
{
return a/gcd(a,b)*b;
}
#define N 4
main()
{ char i;
long num[N]={ 216,360,480,1296 };
long gys=num[0],gbs=num[0];
for(i=1;i<N;i++)gys=gcd(gys,num[i]);
for(i=1;i<N;i++)gbs=lcm(gbs,num[i]);
printf("great common devisor = %ld\n",gys);
printf("least common multiple= %ld\n",gbs);
}
[此贴子已经被作者于2006-6-6 7:39:17编辑过]
落霞与孤鹜齐飞,秋水共长天一色! 心有多大,路有多宽。三教九流,鸡鸣狗盗。兼收并蓄,海纳百川。