首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
有如下程序: #inc1ude<iostream> using namespace std; void function2(int n); void functionl(int n){ if(n<=0)return;
有如下程序: #inc1ude<iostream> using namespace std; void function2(int n); void functionl(int n){ if(n<=0)return;
admin
2019-06-12
68
问题
有如下程序:
#inc1ude<iostream>
using namespace std;
void function2(int n);
void functionl(int n){
if(n<=0)return;
function2(n—2);
)
void function2 (int n){
if(n<=0)return;
functionl(n—1);
}
int main(){
functionl(5);
return 0;
}
下列关于程序运行情况的描述中,正确的是( )。
选项
A、function1运行1次,function2运行2次
B、function1运行2次,function2运行1次
C、function1运行2次,function2运行3次
D、function1运行2次,function2运行2次
答案
D
解析
在主函数中执行functionl(5)时,会调用function2(3),function2(3)又会调用functionl(2),functionl(2)又会调用function2(0),到此相互调用结束。所以funaion1()和function2()各执行了2次。
转载请注明原文地址:https://kaotiyun.com/show/xF8p777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
有如下程序:#includeusingnamespacestd;classTestClass1{public:virtualvoidfun(){cout
有如下程序:#includeusingnamespacestd;classTestClass,{public:TestClass(){cout
如果一个班主任可管理多个班级,而一个班级只被一个班主任管理,则实体“班主任”与实体“班级”之间存在___________联系。
下面有关类模板的说法中不正确的是()。
已知:intn=1:在下面定义引用的语句中,正确的是()。
有3个结点的二叉树有()。
在下面的4个关键字中用来说明虚函数的是()。
阅读以下程序:#includevoidmain(){staticinta[][2]:{5,3,1,2};imi,j,s1=0;for(i=0;i
有三个关系R、S和T如下:由关系R和S通过运算得到关系T,则所使用的运算为()。
有如下程序:#includeusingnamespacestd;intmain(){int*p;*p=9;cout
随机试题
微分方程y"+4y=0的通解y=______.
诊断反流性食管炎最准确的方法是
男,50岁,高血压病多年,近日活动后出现呼吸困难伴左胸痛,咳嗽频繁。咳出为粉红色泡沫样血痰,可能的疾病为
案例某国内大型钢铁联合生产企业,拥有烧结、焦化、炼铁、炼钢、轧钢等完整的钢铁生产流程及配套设施,公司主要产品涵盖了钢材、焦炭、焦黑、苯、煤焦油等。目前拥有员工9000人,配备了专门的安全管理机构和安全管理人员。该企业拥有2600m3高炉一座(1号高炉),
下列关于金融资产的叙述,错误的是()。
资料(一)天阳证券股份有限公司(以下简称天阳证券)成立于上世纪90年代,是一家综合类全国性证券公司。天阳讧王券通过多年的发展,在全国30多个城市设立了100余家证券营业部,业务涉及证券经纪、证券自营、证券承销与保荐、证券投资咨询、证券资产管理、直
Foryears,studieshavefoundthatfirst-generationcollegestudents—thosewhodonothaveaparentwithacollegedegree—la
Thispassagetellsussomethingabout______.Familiesonthelargefarmskeptintouchwitheachotherby______.
Thenear-treblingofuniversitytuitionfeeshasdeterredworking-classboysfromstudyingfordegrees,buthadtheoppositeeff
Writingkeepsusintouchwithotherpeople.Wewritetocommunicatewithrelativesandfriends.Wewriteto【B1】______ourfamily
最新回复
(
0
)