9-- the greatest common divisor

#include <stdio.h>
unsigned fun(unsigned x,unsigned y)
{
unsigned i,j,k;
if(x>y)
{
for(i=y;i>0;i–)
{
if(x%i0&&y%i0)
break;
}
}
else
{
for(i=x;i>0;i–)
{
if(y%i0&&x%i0)
break;
}
}
return i;
}
int main()
{int a,b;
scanf("%d%d",&a,&b);
printf(“common divisor=%d\n”,fun(a,b));
return 0;
}

Guess you like

Origin blog.csdn.net/sfyjjc/article/details/91788968