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