首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else
admin
2010-12-10
53
问题
下列程序的输出结果是( )。 #include<stdio.h> int fun(int x) { int p; if(x==0‖x==1) return 3; else p=x-fun(x-2); return p; } void main() { printf("\n%d",fun(5)); }
选项
A、5
B、3
C、7
D、1
答案
A
解析
本题考查函数的递归调用。在函数递归调用时,fun(5):a=5-fun(3)->fun3:a=3-fun(1)->fun(1):a=3,反推回去fun(3):a=3-3=0->fun(5):a=5-0=5,最后的计算结果为5。
转载请注明原文地址:https://www.kaotiyun.com/show/aBPp777K
本试题收录于:
二级C语言题库NCRE全国计算机二级分类
0
二级C语言
NCRE全国计算机二级
相关试题推荐
将窗体的KeyPreview属性设为True,然后编写如下程序:PrivateSubForm_KeyDown(KeyCodeAsInteger,ShiftAsInteger)PrintChr(KeyCode)
窗体上有一个名称为Label1的标签;一个名称为Timer1的计时器,其Enabled和Interval属性分别为True和1000。编写如下程序:DimnAsIntegerPrivateSubTimer1_Timer() ch=Chr(
已知在4行3列的全局数组score(4,3)中存放了4个学生3门课程的考试成绩(均为整数)。现需要计算每个学生的总分,某人编写程序如下:OptionBase1PrivateSubCommand1_Click() DimsumAsInt
编写如下程序:DimnumAsInteger,rAsInteger,nAsInteger,iAsIntegerDimarr(5)AsIntegerPrivateSubCommand1_Click()num=
设窗体上有一个名称为List1的列表框和一个名称为Check1的复选框数组(下标从0开始)。程序运行时,单击某个复选框,如果列表框中没有该复选框的标题,则把该复选框的标题添加到列表框中,否则从列表框中把该复选框标题删除。PrivateSubCheck
设运行程序时弹出的菜单如图所示.关于该菜单,以下叙述中错误的是( )。
标准模块中有如下程序代码:PublicxAsInteger,yAsIntegerSubvar_pub() x=10∶y=20EndSub在窗体上有1个命令按钮,并有如下事件过程:PrivateSubCommand1_Clic
下面的程序运行时,单击窗体后,窗体上显示的结果是()。PrivateSubForm_Click()Dima(1To6)AsIntegerDimmin1%,i%,j%,n%,t%,k%a(1)=8:a(2)=6
随机试题
若PSW=00,执行下列程序后,CY=______。MOVA,#0FBHMOVPSW,#10HADDA,#7FH
肝主疏泄的功能表现中,最重要的是
渗出性结核性腹膜炎的最佳强化治疗方案是
A.Hb
Thanks_____theGreatGreenWall,thelandproducesmorecrops.
(2004北理工)商业汇票
Accordingtothetext,theoptimisticmoodseemstobeThephrase"madeahashofthings"(Line1,Paragraph6)mostprobablyme
AMessengerfromthePastHispeoplesaidgood-byeandwatchedhimwalkofftowardthemountains.Theyhadlittlereasonto
The______ofaculturalphenomenonisusuallyalogicalconsequenceofsomephysicalaspectinthelifestyleofthepeople.
WheredidJeffgettheinformation?Fromthe______.What’stheinformationabout?Thereceiverisinterestedin______.
最新回复
(
0
)