首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #include<iostream> using namespace std; long fun(int n) { if(n>2) return(fun(n-1)+fun(n-2)); return
有如下程序: #include<iostream> using namespace std; long fun(int n) { if(n>2) return(fun(n-1)+fun(n-2)); return
admin
2013-05-30
34
问题
有如下程序: #include<iostream> using namespace std; long fun(int n) { if(n>2) return(fun(n-1)+fun(n-2)); return 2; } int main() { cout<<fun(3)<<end1; return 0; } 则该程序的输出结果应该是( )。
选项
A、2
B、3
C、4
D、5
答案
C
解析
转载请注明原文地址:https://kaotiyun.com/show/n6Np777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
在下面程序的横线处填上适当的内容,使程序执行后的输出结果为ABCD。#include<iostream>usingnamespacestd;classA{public:A(){cout<<’A’;}
在下面函数的横线处填上适当的内容使该函数能够利用递归方法求解字符串str的长度(不得使用系统提供的字符串处理函数)。intGetLen(char*str{if(【】)return【】;elseretur
下列程序在构造函数和析构函数中申请和释放类的私有成员,请完成该类的实现。classMyclass{public:Myclass(intnum);~Myclass();public:int*p;};
当需要使用ostrstream流类定义一个流对象并联系一个字符串时,应在文件开始使用#include命令,使之包含______文件。
分析以下程序的执行结果【】。#include<iostream.h>classSample{intx,y;public:Sample(){x=y=0;}Sample(inta,intb){x=a;y=b;}~Sam
以下程序执行后的输出结果是【】。#include<iostream.h>main(){inti,m=0,n=0,k=0;for(i=9;i<=11;i++)switch(i/10){case0:m++;n++;break
若调用一个函数,且此函数中没有return语句,则正确的说法是该函数()。
随机试题
根据CCITI、建议,30/32路PCM系统的一次群复接速率为()Mbit/s。
Rememberyoumaybetakentocourtfornotdoingso,andyoumaybefinedifyoucannotprovetothecourtthatyouhavebeenex
正常颈椎前软组织厚度不超过
五脏中五行归类属土的是( )。五脏中五行归类属木的是( )。
固体废物经过堆肥化,体积可缩减至原有体积的()
甲公司采用出包方式建设一条生产线。生产线建设工程于2×17年1月1日开工并支付工程款,至2×17年12月31日尚未完工。为该生产线建设筹集资金的情况如下:2×17年1月1日,按每张98元的价格折价发行分期付息、到期还本的公司债券30万张。该债券每张面值为1
固定汇率制度下,一国的通货膨胀上升,物价上涨,本国货币对内贬值,此时可能出现的情况是()。
Therearemanyfeaturesthat(1)_____amovieasAmerican,butperhapsthemost(2)_____isthethemeoftheloner-hero(孤胆英雄).I
Whoeversaidthatvictoryhasmanyfathersanddefeatisanorphan,surelyhadneverheardoftheWorldTradeOrganization(WTO)
Sportisnotonlyphysicallychallenging,butitcanalsobementallychallenging.Criticismfromcoaches,parents,andotherte
最新回复
(
0
)