#include
int gcd(int,int);
void main()
{
int u,v,g,l;
scanf("%d %d"棚差虚,&u,&v);
g=gcd(u,v);
printf("最大公约数链燃:%d\n",g);
l=u*v/g;
printf("最小公倍数:%d",l);
}
int gcd(int a,int b)
{
int temp = a;
if(0 == a )
{
return b;
}
if( 0 == b)
{
return a;
}
if(a > b)
{
a = b;
b = temp;
}
int c;
for(c = a % b ; c > 0 ; c = a % b)
{
a = b;
b = c;
}
return b;
}
===============================
hcf函数有点问题,而且少了个反大括号,庆喊我重新写了一个,你看看吧!呵呵……
#include
int hcf(int,int);
int lcd(int,int,int);
void main()
{
int u,v,h,l;
scanf("%d,%d",&u,&v);
h=hcf(u,v);
printf("H.C.F=%d\戚纤n",h);
l=lcd(u,v,h);
printf("L.C.D=%d",l);
}
int hcf(int u,int v)
{
int t,r;
if(v>u)
{
t=u;
u=v;
v=t;
///////////////////////////////////////////梁姿///////////////////橡仔绝////////你错的地方
}
while((r=u%v)!=0)
{
u=v;
v=r;
}
return (v);
}
int lcd(int u,int v,int h)
{
return (u*v/h);
}
ongyue(int a,int b);
int gongbei(int a,int b);
void main()
{
int a,b,temp,gy,gb;
clrscr();
printf("input two numbers please:");
scanf("%d,%d",&a,&b);
gy = gongyue(a,b);
gb = gongbei(a,b);
printf("最大公约数:%d\n",gy);
printf("罩基最小公倍数:%d\n",gb);
getch();
}
int gongyue(int a,int b)
{
int temp;
while(b!=0)
{
temp=a%b;
a=b;
b=temp;
}
return a;
}
int gongbei(int a,int b)
{
int num,num1,temp;
num=a;
num1=b;
if(num >= num1)
{
temp=num;
num=num1;
num1=temp;
}
temp = gongyue(a,b);
return (num*num1/temp);
}
不明白宴州的发消息给我
另外,虚机团上产品团购,超级便宜晌闷蔽
给你写个简雀配单的!桥宽
#include
main()
{
int m,n,i,t;
scanf("%d%d",&m,&n);
for(i=m;i>=1;i--)
{
if(m%i==0&&n%i==0) break;
}
printf("%d\敏岁亮n",i);
t=(m*n)/i;
printf("%d\n",t);
}
你忘了个花括号,并且本来就是错的思路,你带进去两个数试试