首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有以下程序 fun(intx) {intp; if(x=0‖x=1)return(3); p=x-fun(x-2); returnp; } main( ) {printf(’’%\n’’,fun(7));) 执行后的输出结果是
有以下程序 fun(intx) {intp; if(x=0‖x=1)return(3); p=x-fun(x-2); returnp; } main( ) {printf(’’%\n’’,fun(7));) 执行后的输出结果是
admin
2014-06-18
15
问题
有以下程序
fun(intx)
{intp;
if(x=0‖x=1)return(3);
p=x-fun(x-2);
returnp;
}
main( )
{printf(’’%\n’’,fun(7));)
执行后的输出结果是
选项
A、3
B、7
C、0
D、2
答案
D
解析
因为在函数fun(intx)中,如果参数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://jikaoti.com/ti/gpn0FFFM
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
以下程序是从终端读入数据到数组中,统计其中正数的个数,并计算它们的和。请填main(){inti,a[20],sum,count;sum=count=【】;for(i=0;i<20;i++)scanf("%d
下列程序的输出结果是16.00,请填空:main()}inta=9,b=2;floatx=【】,y=1.1,z;z=a/2+b*x/y+1/2;printf("%5.2f\n",z);
在16位C编译系统上,若定义longa;,则能给a赋40000的正确语句是
在面向对象的程序设计中,用来请求对象执行某一处理或回答某些信息的要求称为【】。
以下对枚举类型名的定义中正确的是()。
已知a、b、c为整型变量,若从键盘输入5<空格>6<空格>7<回车>,使a的值为5,b的值为6,c的值为7,则下列选项中正确的输入语句是()。
下列关键字中,不属于C语言变量存储类别的是______。
有以下程序段:main(){inta=5,*b,**c;c=&b;b=&a;}程序在执行了c=&b;b=&a;语句后,表达式**c的值是______。
有以下函数定义:voidfun(intn,doublex){……}若以下选项中的变量都已正确定义并赋值,则对函数fun正确调用语句是______。
请读程序片段(字符串内没有空格字符):printf("%d\n",strlen("ATS\n012\1\\"));上面程序片段的输出结果是_______。
随机试题
专利申请人对专利复审委员会的复审决定不服的,可以自收到通知之日起( )内向人民法院起诉。
侧支性抑制的形成是由于
潮汐表中的潮高基准面又称为()。
根据《发布证券研究报告执业规范》的规定,署名的证券分析师应()。Ⅰ.对其署名的证券研究报告的内容负责Ⅱ.对其署名的证券研究报告的观点负责Ⅲ.对证券研究报告进行质量审核Ⅳ.明确质量审核程序和审核人员职责,加强质量审核管理
下列说法中不正确的有()。
国家计划明确的宏观调控目标和总要求,是制定()政策的主要依据。
左边给定的是纸盒的外表面,下面哪一项能由它折叠而成?
社会事实指的是存在于社会之中的一类具有非常特殊性质的事实。这类事实存在于个人之身外,由具有使个人不能不服从的行为方式、思维方式和感觉方式构成,对于个人的行为具有约束力和强制性。它潜移默化地存在于人们的日常生活之中,个人如果触犯它就会受到惩罚。根据上述定义,
下列有关需求的表述,不正确的是()。
BonAppetiteA)Wealllovethefoodwegrowupon,butwealsoseekadventureinthefoodwehavenevertasted.Ahugelypopular
最新回复
(
0
)