#include <stdio.h>
#include <stdlib.h>
int a,b
int gcd(int x,int y)
{
if (x%y==0)
return y
else
return gcd(y,x%y)
}
int main()
{
scanf("%d%d",&a,&b)
printf("%d\n",gcd(a,b))
return 0
}
c语言中用户自定义函数的格式:函数返回类型
函数名(参数列表)
{
代码段;
return
函数返回值;
}
例如:
int test(int value)
{
value += 10
return value
}
上面示例定义了一个名为test的函数,其返回值为int型,参数为int型,返回值为参数与10之和。
注:函数类型为void时,不可有return语句。