首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
admin
2009-05-15
76
问题
递归函数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://kaotiyun.com/show/05jZ777K
本试题收录于:
程序员上午基础知识考试题库软考初级分类
0
程序员上午基础知识考试
软考初级
相关试题推荐
阅读以下说明,回答问题。[说明]某公司要组建一个小型Windows局域网,包括1台服务器和10台PC机,网络结构如下图所示。该公司在服务器上建立自己的商业网站,网站域名定为“www.economical.com”。该网络的物理拓扑结构
阅读以下Windows2003系统架构E-mail服务器的技术说明,根据要求回答问题1~问题5。【说明】某企业局域网内部基于WindowsServer2003操作系统提供的POP3服务和SMTP服务,架构了一台电子邮件服务器(IP地址为19
在一台计算机上安装完成WindowsServet2003服务器及相应的服务组件。如果这台服务器是域控制器,为方便用户管理和资源授权需要建立用户组,那么组有哪些类型?组的作用域有哪些?
(67):The process of identifying and correcting errors in a program.
A local area network(LAN)is the communication of a number of computers by(66)connecting to each one in a single location, usuall
(66)is a channel’ s capacity which directly reflects the data transfer rate of the channel.(67)functions in a NetWare network wh
(74)is a network layer device that supports multiple LAN interfaces and segments LANs into smaller collision and broadcast domai
WAP uses(71), which includes the Handheld Device Markup Language (HDML) developed by Phone.com. WML can also trace its roots to
Users also need(71)systems to help them explore the web and discover interesting data sources and interfaces that support differ
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
随机试题
根据我国现行宪法和立法法的规定,下列选项中哪一行为不符合法律规定?
开发性金融机构的主要作用是()。
人力资源需求预测的步骤。
本病诊断为何病本病治法为
“两算”对比表指的是同一工程内容的_________的对比分析表。()
中荷大陆桥与海运比较,时间可节省()。
下列各项中,应计入企业管理费用的是()。
下列对公安机关人民警察盘问、检查的表述正确的是()。
从一名技校毕业的普通工人到国家级技能大师,周建民在简单、重复的工作中始终力求极致,以高超的技能打造最优质的产品,并把这种追求坚持了35年。对此,请谈谈你的看法。
在考生文件夹下,打开文档word.docx,按照要求完成下列操作并以该文件名(word1.docx)保存文档。【文档开始】入世半年中国气车市场发展变化出现五大特点在中国加入WTO半年多的时间里,中国气车市场发生了深刻的变化,这种变化呈现出五大特点:产
最新回复
(
0
)