首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序: #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
2020-04-18
65
问题
有以下程序:
#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是一个递归函数,所以主函数中执行ffa,2)时,其执行过程是a[3]+f(a,1)=a[3]+a[2]+f(a,0)=7。
转载请注明原文地址:https://kaotiyun.com/show/1kCp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
有以下程序main(){inti=1;i=i^i;printf("%d\n",i);}程序运行后的输出结果是
若有以下程序main(){intc;c=10^5:printf("%d\n",c);}则程序的输出结果是
函数fun的功能是在a所指的具有n个元素的数组中查找最大值并返回给调用函数,函数不完整。intfun(int*a,intn){int*p,*s;for(P=a,s=a;P—a
下列叙述中正确的是()。
存储在计算机内有结构的数据集合是()。
下列关于C语言文件的叙述中正确的是()。【09年9月】
二叉树的中序序列为BDCA,后序序列为DCBA,则前序序列为()。
数据流图(DFD)中的有向箭头(→)表示()。
程序流程图中带有箭头的线段表示的是
以下选项中不属于C语言标识符的是
随机试题
下列各项中,属于常规授权的是
骨骼肌细胞兴奋一收缩耦联的关键因素是()。
根据资料,回答下列问题:2012年,某地区农作物播种总面积达到1625.55万亩,同比增长4.6%。其中,粮食和蔬菜播种面积大幅增长,分别为459.40万亩、109.06万亩,同比增长32.7%和30.5%;棉花、油料和甜菜播种面积下降,分别为698.
(2014年第31题)中华民族的爱国主义优良传统源远流长,内涵极为丰富,下列诗句中反映爱国主义优良传统的有
Theterme-commercereferstoallcommercialtransactionsconductedovertheInternet,includingtransactionsbyconsumersandb
排序是计算机程序设计中的一种重要操作,常见的排序方法有插入排序、______和选择排序。
Whatdidwomenusuallydobeforetheirmarriage?
Wheredoesthewomanwork?
"Museum"isaslipperyword.Itfirstmeant(inGreek)anythingconsecratedtotheMuses:ahill,ashrine,agarden,afestival
DearMr.Green,Pleaseshipusorangemarmalade(柑橘酱)asperthefollowingterms:Quantity:20,000jarsUnit:1kgperj
最新回复
(
0
)