天天看点

c语言中如何交换两个数的大小,[讨论]用辗转相除法用比较交换两个数的大小吗...

#include

#include

int i;

void main()

{ int hcf (int p,int r);

int hcd (int p,int r);

int j, n,m,temp;

printf("intput m and n\n");

scanf("%d,%d",&m,&n);

if(m

{temp=m;

m=n;

n=temp;

}

i=hcf (m,n);

j=hcd (m,n);

printf("theH.C.F of m and n is :%d",i);

printf("the H.C.D of m and n is :%d",j);

}

int hcf (int p, int r)

{ int x,y;

if( p%r==0)

y=r;

else

{if (x==p%r!=0)

{p=r;

r=x;

}

y=r;

}

return y;

}

int hcd (int p,int r)

{int y;

y=p*r/i;

return y;

}

这样怎么有错误啊