用c语言求最大公约数和最小z公倍数的函数


 1.

```#include<stdio.h>
#include<stdlib.h>
int fun(int a,int b)
{ int i,t,n,f;
f=a*b;
if(a<b)
{t=a;
a=b;
b=t;
}
while(b!=0)
{n=a%b;
a=b;
b=n;
}
i=f/a;
printf("%5d%7d",a,i);//记住最后的最大公约数输出的是除数a;
return(a);
}
int main()
{int a,b;
scanf("%d%d",&a,&b);
int fun(int,int);
fun(a,b);
system("pause");
return 0;
}

猜你喜欢

转载自blog.csdn.net/hht113353407267/article/details/84839938
今日推荐