首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #include<stdio.h> int f(int t[],int n); main() { int a[4]={1,2,3,4},s; s=f(a,2);printf(’’%d\n’’,s);}
有以下程序: #include<stdio.h> int f(int t[],int n); main() { int a[4]={1,2,3,4},s; s=f(a,2);printf(’’%d\n’’,s);}
admin
2020-07-28
22
问题
有以下程序:
#include<stdio.h>
int f(int t[],int n);
main()
{ int a[4]={1,2,3,4},s;
s=f(a,2);printf(’’%d\n’’,s);}
int f(int 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/hF3p777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
下面属于整数类I实例的是
下面对软件测试和软件调试有关概念叙述错误的是
以下叙述中正确的是
若有以下程序段structst{intn;structst*next;};structsta[3]={5,&a[1],7,&a[2],9,’\0’},*p;p=&a[0];则以下选项中值为6的表达式是
设表的长度为n。在下列结构所对应的算法中,最坏情况下时间复杂度最低的是
若有定义:inta[2][3];,以下选项中对a数组元素正确引用的是
对如下二叉树进行后序遍历的结果为
下列选项中不属于面向对象程序设计特征的是()。【07年4月】
下面说法正确的是()。
通常软件测试实施的步骤是()。
随机试题
下列哪个组织享有行政主体资格?
法律规则的特征有哪些?()
朱某自诉陈某犯诽谤罪,法院审理后,陈某反诉朱某侮辱罪。法院审查认为,符合反诉条件,合并审理此案,判处陈某有期徒刑一年,判处朱某有期徒刑一年。两人不服,均以对对方量刑过轻、己方量刑过重为由提出上诉。关于二审法院的判决,下列哪些选项是正确的?(2010年卷二7
目视助航灯光系统工程质量情况实测检查内容包括()。
【背景资料】某机电安装公司承担北方某城市三台蒸发量25t/h,蒸发压力为2.5MPa的散装工业锅炉的安装工程。开工前,项目经理部未办理任何手续即根据施工组织设计进行了全面的质量策划,并指令专业工程师编制质量控制程序。在施工过程中发现某焊工的合格证
根据个人所得税法律制度的规定,下列应按“个体工商户的生产、经营所得”项目缴纳个人所得税的有()。
下列作品与作者相对应的是()。
请谈一谈你对科学发展观的理解和认识。
一位科学家发明了一项新产品,他利用手上的一些储蓄,又贷了一些款,自己开办了一家企业。半年后,企业效益下滑,于是他高薪聘请了一名总经理,自己任董事长兼搞开发,终于使企业迅速崛起为一家大型公司。由此可见( )。
假定在图片框控件Picturel中装入了一个图形,为了在程序运行时清除该图形,则应使用下列哪种方法()。
最新回复
(
0
)