首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 fun(int x) main() {int p; { if(x==0}‖x==1)return(3);printf("%d\n",fun(7)); p=x-fun(x-2); } re
有以下程序 fun(int x) main() {int p; { if(x==0}‖x==1)return(3);printf("%d\n",fun(7)); p=x-fun(x-2); } re
admin
2020-07-28
15
问题
有以下程序
fun(int x) main()
{int p; {
if(x==0}‖x==1)return(3);printf("%d\n",fun(7));
p=x-fun(x-2); }
return p;}
执行后的输出结果是
选项
A、3
B、7
C、0
D、2
答案
D
解析
因为在函数fun(int x)中,如果参数x等于0或等于1时,返回值为“3”。否则“p=x-fun(x-2)”这是一个递归函数,所以在主函数调用fun(7)的时候,其过程为:“fun(7)=7-fun(5)=7-(5-fun(3))=7-(5-(3-fun(1)))=7-(5-(3-3))=7-5=2”,所以最后的输出结果为2。
转载请注明原文地址:https://kaotiyun.com/show/j93p777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
数据结构主要研究的是数据的逻辑结构、数据的运算和()。
以下语句定义正确的是()。
请编写函数fun,函数的功能是:将放在字符串数组中的M个字符串(每串的长度不超过N),按顺序合并组成一个新的字符串。例如,字符串数组中的M个字符串为AAAABBBBBBBCC则合并后的字符.串的内容应是:A
软件设计中模块划分应遵循的准则是
结构化程序设计的基本原则不包括
以下选项中,值为1的表达式是
以下选项中可用作C程序合法实数的是
由以下while构成的循环,循环体执行的次数是intk=0;while(k=1)k++;
以下关于简单程序设计的步骤和顺序的说法中正确的是()。【10年9月】
随机试题
Forthreedecadeswe’veheardendlesslyaboutthevirtuesofaerobic(increasingoxygenconsumption)exercise.Medicalauthoriti
A.缺血性肌痉挛B.压疮C.尿道、膀胱损伤D.周围神经损伤E.缺血性骨坏死脊柱骨折,脊髓损伤常并发
可用熏洗法治疗的疾病是
通过拮抗盐皮质激素受体而产生利尿作用的药物是
背景依据《建设工程施工合同(示范文本)》(GF—2017—0201),某机场施工单位与另一施工单位于2018年1月1日签订了机场站坪扩建工程建设的分包合同,明确由发包人供应材料与工程设备。在双方一般约定中,涉及哪些内容?
按照地理有效范围,计算机网络可以分为()。
人体体格测量资料可作为营养状况的综合观察指标,不同年龄组选用的指标不同,5~20岁组应选用()指标。
Apersonmayhaveanideaabouthimselfthatwillpreventhimfromdoinggoodwork.Hemayhavetheideathatheisnotcapable
新民主主义革命时期,党的建设包括()
有三个关系R、S和T如下:则由关系R和S得到关系T的操作是( )。
最新回复
(
0
)