首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
以下C程序段的输出结果是(35)。 #include<stdio.h)long fun(int n){ long s; if(n==1 || n==2) s=2; else s=n
以下C程序段的输出结果是(35)。 #include<stdio.h)long fun(int n){ long s; if(n==1 || n==2) s=2; else s=n
admin
2009-02-15
23
问题
以下C程序段的输出结果是(35)。 #include<stdio.h)long fun(int n){ long s; if(n==1 || n==2) s=2; else s=n+fun(n-1); return s; } void main(){ printf("\n%1d",fun(4)); )
选项
A、5
B、7
C、9
D、11
答案
C
解析
本试题考查函数的递归调用。程序在n=1或n=2时是出口条件,不再递归,否则一直执行s=n+fun(n-1)的操作。展开此求和公式,有s=n+fun(3)=4+3+fun(2)=4+3+2=9。另外,如果调用函数fun的实参≥2,则出口条件“n==1”的判定就不需要了。
转载请注明原文地址:https://kaotiyun.com/show/nyjZ777K
本试题收录于:
程序员上午基础知识考试题库软考初级分类
0
程序员上午基础知识考试
软考初级
相关试题推荐
阅读以下说明,回答问题1~5,将答案填入答题纸对应的解答栏內。[说明]某公司有一个局域网,在ISP申请了Internet接入,接入方式是以太网,ISP分配给了一个固定的IP地址为222.152.199.33、子网掩码为255.255.255.
阅读以下说明,回答问题1~5,将解答填入对应的解答栏内。[说明]某公司内部有一个采用TCP/LP作为传输协议的100BaseTX局域网,包括1台服务器和20台客户机,通过一台16端口的交换机与一台8端口的共享集线器级联,其网络拓扑结构如下图所示
阅读下列说明,回答问题1至问题3。[说明]某网站登录系统采用MD5对用户信息进行加密,用户登录界面为login.html,errorasp用于显示登录出错信息,list.asp用于显示正确登录后页面。[login.html文档的内容
阅读以下说明,回答问题1至问题5,将解答填入解答栏内。[说明]某公司网络拓扑结构如图3-1所示。处置了以上故障后,内部PC仍然无法访问Internet,为定位故障,在pc1上用ping命令测试连通性的结果如图3-4所示,结果说明故障原因可能是(1
阅读下列说明。[说明]某公司用ASP+Access数据库开发了库存查询系统,该系统用户登录界面如图5·1所示:该系统采用B/S三层结构,请根据B/S三层结构的工作过程,完成如图5-2所示:下面是登录系统中check.asp的部分代
阅读以下说明,回答问题。【说明】某单位网络拓扑结构如图2一1所示,FTP服务器的域名为xhftp.SoftwareExam.com。在该单位综合布线时,连接楼A与楼B的布线子系统为(1);楼A内网管中心服务器群至核心交换机的布线子系统为(
在Windows系统中,如果用户要整理D盘上的碎片,可选中D盘,(12),单击“开始整理”按钮,在弹出的对话框中单击“碎片整理”按钮即可;通过设置文件的(13),可以使其成为“隐藏”文件。
在Excel中,通过冻结或者拆分窗格可以在滚动工作表时始终保持部分数据可见。下图中(16),当鼠标指针在上述位置变为(17)后,将该框拖至所需的位置即可。
设机罪码的长度为8位,已知X、Z为带符号的纯整数,Y为带符号的纯小数,[X]原+[Y]补+[Z]移=11111111,求出X、Y、Z的十进制真值为:X=(16),Y=(17),Z=(18)。
在多媒体计算机中,语音和音乐是最基本的功能之一。实现模拟音频数字化的主要过程是(12)、量化和编码。人们通常用8位声卡或16位声卡来区分不同的声卡质量。若量化位是8位,并规定输入信号幅度为0~3V,则每一量化单位约对应(13)mV。声卡需使用计算机的资源,
随机试题
下列不适合做PNF伸展练习的肌肉是()。
计算定积分
下列情况不宜使用磺胺药,但除外:
门萨的成员都很聪明,小李很聪明,所以小李可以加入门萨。以下哪项与题干逻辑错误一致?()
海派文化的重要标志是()。
简述幼儿自我评价的发展的特点。
马克思认为:“一种商品变成货币,首先是作为价值尺度和流通手段的统一。换句话说,价值尺度和流通手段的统一是货币。”这句话说明了()
[*]
Credibilityaboutmessagesishigh,becausetheyarereportedinindependentmedia.Anewspaperreviewofamoviehasmorebeli
Europeisnotagender-equalityheaven.Inparticular,thecorporateworkplacewillneverbecompletelyfamily-friendlyuntilwo
最新回复
(
0
)