首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
admin
2009-05-15
83
问题
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
选项
A、if n>1 then return 1 else return n+f(n-1)
B、if n>1 then return 1 else return n+f(n+1)
C、if n>1 then return 0 else return n+f(n+1)
D、if n<1 then return 0 else return n+f(n-1)
答案
D
解析
根据题意,当n<1时结束递归,函数返回0,否则返回n+f(n-1)进行递归运算。
转载请注明原文地址:https://www.kaotiyun.com/show/05jZ777K
本试题收录于:
程序员上午基础知识考试题库软考初级分类
0
程序员上午基础知识考试
软考初级
相关试题推荐
某单位拟建立一个Intranet,建立自己的Web服务器、DNS服务器、Email服务器和内部业务服务器,有一批客户机联网,要求这些计算机有的可以连接到Internet,但只允许访问自己的Web服务器。请做出规划,解决如下问题。
区域文件窗口如图2-3所示,默认情况下区域文件名为(1)A.test.com.dnsB.test.com.wwwC.test.com.ftpD.test.com在如图2-4所示的下拉菜单中选择(4),可为ftp.t
阅读以下Linux系统中关于IP地址和主机名转换的技术说明,根据要求回答问题1~问题4。【说明】计算机用户通常使用主机名来访问网络中的结点,而采用TCP/IP协议的网络是以IP地址来标记网络结点的,因此需要一种将主机名转换为IP地址的机制。
(70):A graphical bar With buttons that perform some of the most common commands.
(66)is a one-way function that takes an arbitrarily long piece of plaintext and from it computes a fixed,length bit string.(67)i
SQL Server is a RDBMS( Relational Database Management System)made by Microsoft. This means that the data is stored in two dimens
在某个支持SNMPv2 MIB组的代理中,snmpSerialNo对象的当前值为2007。这时,该代理站同时收到两个管理站发来的set请求,这两个set请求的snmpSerialNo值都是2007,当代理站处理完这两个set请求后,其snmpSerialN
The major problem with E-mail is that it is(71)easy to use that people can become(72)with messages(73)they can possibly answer i
The Programming languages are designed to(74)the communication between human and computers.
(73)isamultimediaInternetservicethatallowsuserstotraversetheInternetbymovingfromonedocumenttoanothervialink
随机试题
下列文学常识表述错误的是()
右主支气管的叙述正确的是()。
对于相同的横截面面积,同一梁采用( )截面,其强度最高。
按导致事故的直接原因将生产过程中的危险分为()等危险、有害因素。
以下网址的表示中,正确的是()。
现代教育、素质教育、社会主义新时期的教育最根本的特点是()。
工程管线敷设有其规范,当工程管线交叉敷设时,自地表面向下排列时要考虑管道内的介质及管线输送方式、埋深等问题,以确定各管道垂直间距。管线排列的顺序宜为()。
若将在[0,2]上展开成正弦级数,则该级数的和函数S(x)为_______
下列关于计算机技术指标的描述中,正确的是()。
RecentlyBroadpointCommunications,afledg-ling(刚起步的)mediacompany,startedhandingoutfreelong-distancetelephonecalls.In
最新回复
(
0
)