我正在尝试在我的cuniix编辑器中运行下面的程序,以查看它是否有效,但是我一直遇到分段错误,我不知道为什么。
#include <stdio.h>
int main(void)
{
int f(int, int);
int x=4;
int y=2;
int sum;
sum = f(x,y);
printf("The result of applying f to %3d and %3d is %3d\n",x,y,sum);
return 0;
}
int f(int x, int y)
{
int ans;
if(x ==y)
ans = x;
else
ans = 1 + f(x,y-2);
return (ans);
}