首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include int flint t[],int n); main() {int a[4]={1,2,3,4},s; s=f(a,2);printf("%d\n",s); } i
有以下程序: #include int flint t[],int n); main() {int a[4]={1,2,3,4},s; s=f(a,2);printf("%d\n",s); } i
admin
2021-07-09
20
问题
有以下程序:
#include
int flint t[],int n);
main()
{int a[4]={1,2,3,4},s;
s=f(a,2);printf("%d\n",s);
}
int flint t[],int n)
{ if((n>0)&&(n<5))return t[n+1]+f(t,n-1);
else return 0;
}
程序运行后的输出结果是( )。
选项
A、4
B、7
C、10
D、6
答案
B
解析
本题主要考查的是函数的递归调用,子函数f是一个递归函数,所以主函数中执行f(a,2)时,其执行过程是a[3]+f(a,1)=a[3]+a[2]+f(a,0)=7。
转载请注明原文地址:https://kaotiyun.com/show/Iokp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
在软件开发中,需求分析阶段产生的主要文档是()。
若要求从键盘读入含有空格字符的字符串,应使用函数
设栈的顺序存储空间为S(1:m),初始状态为top=0。现经过一系列正常的入栈与退栈操作后,top=m+1,则栈中的元素个数为()。
定义部门关系模式:部门(部门号,部门名,部门成员,部门总经理),使它不满足第一范式的属性是
已知大写字母A的ASCII码是65,小写字母a的ASCII码是97。以下不能蒋变量c中的大写字母转换为对应的小写字母的语句是
软件生命周期中的活动不包括
软件需求规格说明书在软件开发中的作用不包括()。
以下选项中合法的标识符是
使用VC++2010打开考生文件夹下blank1中的解决方案。此解决方案的项目中包含一个源程序文件blank1.c。在此程序中,通过定义学生结构体变量,存储学生的学号、姓名和三门课的成绩。函数fun的功能是:将形参a中的数据进行修改,把修改后的数据作为函数
使用VC++2010打开考生文件夹下prog1中的解决方案。此解决方案的项目中包含一个源程序文件prog1.c。在此程序中,请编写函数fun,该函数的功能是:统计各年龄段的人数。N个年龄通过调用随机函数获得,并放入主函数的age数组中。要求函数把0—9岁年
随机试题
湿淫证致病特点是
胃、十二指肠溃疡急性穿孔最常见的是
对于可能出现小型崩塌的地带,应实施()。
某银行在2008年4月20日以100元的价格买入债券,5个月后该银行以110元的价格卖出债券,这一年内债券没有付息,则该银行从2008年4月20日到2008年9月20日的债券持有期收益率为( )。
物业管理区域内,代表和维护全体业主在管理物业活动中的合法权益,并决定一切物业管理事项的是()。
司机小玉,由于曾在特警队中训练过特技驾驶,对自己的开车技术深信不疑,且自恃技术高超,经常做些“高难度动作”,从未失手。一日途经一渡口时,为向朋友炫耀,违反渡口汽车应顺跳板缓行驶上渡船的规定,企图不经跳板直接从岸边“飞车上船”,结果汽车上船时造成渡船倾覆。小
Itwouldbeablessingforthehumanraceifthemosquitocouldbeeradicated.
BGP-4协议是一种_________路由协议。
有下面程序代码:PrivateSubCommand1_Click()DimaAsStringa="COMPUTER"n=search(a,"T")PrintIIf(n=0,"未找到",
WhatdidKlaraoriginallywanttodoherprojecton?Whichfacilitiesmightinfluencehousingprices?
最新回复
(
0
)