main()
{
int a,b,i,k,s;
int gys(int a,int b);
int gbs(int a,int b);
printf("Please input two number:\n");
scanf("%d %d",&a,&b);
k=gys(a,b);
s=gbs(a,b);
printf("gys=%d,gbs=%d\n",k,s);
getch();/*win-tc*/
}
int gys(int a,int b)/*定义求最大公因数的函数*/
{
int i,k,t;
if (a>b){t=a;a=b;b=t;}/*当a>b时将ab互换,保证最大公因数不会大于最小数*/
for (i=1;i<=a;i++)
{
if(a%i==0 && b%i==0) k=i;
}
return k;
}
int gbs(int a,int b)
{
int i,s,t;
if(a>b){t=a;a=b;b=t;}
for (i=1;i<=a*b;i++)
{
if(b*i % a==0) {s=b*i;break;}/*加上break就行了*/
}
return s;
}