选择题
有下列程序:
#include <stdio.h>
int fun(int a,int b)
{ if(b==0) return a;
else return(fun(--a,--b));
}
void main()
{ printf('%d\n',fun(4,2));}
程序的运行结果是______。
A、
1
B、
2
C、
3
D、
4
【正确答案】
B
【答案解析】
本题考查递归函数的使用。fun(4,2)->fun(2,0),由于b等于0,故返回值为2。反之,fun(4,2)=2。
提交答案
关闭