首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
递归函数f(n)的功能是计算1+2+…+n,且n≥1,则f(n)的代码段是(49)。
admin
2009-05-15
98
问题
递归函数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
程序员上午基础知识考试
软考初级
相关试题推荐
以下是用ASP实现的一个网络留言系统。用IE打开网页文件index.asp后的效果如下图所示。index.asp文档的内容如下。<!--#includefile="conn.asp"--><html><head><title
阅读以下说明,回答问题。[说明]在一台计算机上安装完成WindowsServer2003服务器及相应的服务组件。如果希望在该服务器上D盘(卷)中实现磁盘配额功能,则该卷必须是什么样的文件系统?
试题二阅读以下说明,回答【问题1】至【问题4】,将解答填入对应的解答栏内。【说明】某单位网络结构及各接口IP地址如图2-1所示,路由器R1的路由表结构及外部网络访问内网的路由记录如表2-1所示。【问题2】填充表2-2,
One solution to major security problems is(73),which are frequently installed to fix known security holes.
(52)主要包括网络模拟攻击、漏洞检测、报告服务进程、提取对象信息以及评测风险、提供安全建议和改进措施等功能。
In the following essay, each blank has four choices. Choose the most suitable one from the four choices and write down in the an
(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
There are several applications called Web(69)that make it easy to access the World Wide Web, two of the most popular being Netsc
Because Web servers are platform and application(71)they can send or request data from legacy or external applications including
(72)isasequenceoflettersanddigits,thefirstcharactermustbealetter.
随机试题
心脏病孕妇最容易发生心力衰竭时期为
A、生大黄B、大黄炭C、姜黄连D、酒黄连E、黄精泻下作用极微,并有凉血化瘀止血的饮片是()。
关于建设单位和相关单位安全生产责任,下列说法错误的是()。
担保的充分性和有效性分别指()。
勘探:矿石:工厂
一直到二十世纪九十年代中期以前,我们都在试图重新寻找自己的精神家园。钱穆、钱钟书和陈寅恪的著作和传记成了畅销书,《顾准文集》《顾准日记》______于市场,这个中国“市场经济第一人”,坚持学术自由的孤独者形象______了人们对于知识分子角色的期许,《傅雷
试述北宋的三次兴学运动及其主要内容。
下面含有非常见的信息系统开发方法体系的是
WewereshockedtofindthatMarydid’tknowherguest’sname.
Allthecommoditiessoldinthatshoparegivenoneyear’s______.
最新回复
(
0
)