选择题
有以下程序
#include<stdio.h>
void fun(int n,int *s)
{ int f;
if(n==1) *s=n+1 ;
else
{ fun(n-1,&f);
*s=f;
}
}
main()
{ int x=0;
fun(4,&x);
printf('%d\n',x);
}
程序运行后的输出结果是______。
A、
3
B、
4
C、
2
D、
1
【正确答案】
C
【答案解析】
[考点] 字符串、函数递归、标识符的作用域和存储类 本题考查函数的递归调用。将函数参数带入函数中,经过一步步递归即可得到结果,结果为2。
提交答案
关闭