选择题
14. 有以下程序
#include<stdio.h>
int fun(int a,int b)
{ if(b==0) retum a;
else return(fun(--a,--b));
}
main()
{printf("%d\n",fun(4,2));}
程序的运行结果是______。
【正确答案】
B
【答案解析】 由程序可知,函数fun(int a,int b)是一个递归函数。所以当主函数中调用fun(4,2)时,其执行过程如下:fun(4,2)->fun(3,1)->fun(2,0),其返回值为2。所以正确答案为选项B。