首页
外语
计算机
考研
公务员
职业资格
财经
工程
司法
医学
专升本
自考
实用职业技能
登录
计算机
下面程序的输出结果是【 】。 #include <iostream> using namespace std; int d=1; fun(int p){ static int d = 5; d+ =p;
下面程序的输出结果是【 】。 #include <iostream> using namespace std; int d=1; fun(int p){ static int d = 5; d+ =p;
admin
2009-01-15
22
问题
下面程序的输出结果是【 】。
#include <iostream>
using namespace std;
int d=1;
fun(int p){
static int d = 5;
d+ =p;
cout<<d;
return (d) ;
}
void main ( ) {
int a =3;
cout<<fun ( a + fun (d) )<<endl;
}
选项
答案
61515
解析
先调用fun(d),d=1执行,局部静态变量d的值为6,输出6,返回值为6;再调用 fun(a+fun(d)),即fun(9)执行,静态局部变量的值为15,输出15,返回值为15;最后再执行 main方法中的输出语句,输出fun(a+fun(d))的值15。所以程序输出结果为61515。
转载请注明原文地址:https://kaotiyun.com/show/cZkp777K
本试题收录于:
二级C题库NCRE全国计算机二级分类
0
二级C
NCRE全国计算机二级
相关试题推荐
下列给定程序中,函数fun的功能是:用下面的公式求π的近似值,直到最后一项的绝对值小于指定的数(参数num)为止。例如,程序运行后,输入0.0001,则程序输出3.1414。请改正程序中的错误,使它能得出正确的结果。注意:不
设某二叉树的后序序列为CBA,中序序列为ABC,则该二叉树的前序序列为
公司中有多个部门和多名职员,每个职员只能属于一个部门,一个部门可以有多名职员。则实体部门和职员间的联系是()。
数据流图中带有箭头的线段表示的是()。
已知char*s,下面正确的语句是()。
编写函数fun,其功能是:实现两个字符串的连接(不要使用库函数strcat),即把p2所指的字符串连接到p1所指的字符串的后面。例如,分别输入下面两个字符串:FirstString——SecondString程序运行后的输出
使用VC++2010打开考生文件夹下blank1中的解决方案。此解决方案的项目中包含一个源程序文件blank1.c。在此程序的主函数中,已给出由结构体构成的链表结点a、b、c,各结点的数据域中均存入字符,函数fun()的作用是:将a、b、c三个结点链接成一
以下能正确表述算式sin(2πr+30°)的C语言表达式是()。
给定程序modi1.c的主函数中,将a、b、c三个结点链成一个单向链表,并给各结点的数据域赋值,函数fun()的作用是:累加链表结点数据域中的数据作为函数值返回。请改正函数fun中指定部位的错误,使它能得出正确的结果。注意:不要改动ma
有如下函数模板定义:template<classT>Tfunc(Tx,Ty){returnx*x+y*y;}在下列对func的调用中,错误的是______。
随机试题
大叶性肺炎灰色肝样变期的临床表现和红色肝样变期不同点在于
患者,女,41岁。发现颈部肿大6年,近半年来常感心悸,多汗,食量加大,检查:无突眼、甲状腺Ⅱ度肿大、结节状,脉搏116次/分,心、肺、腹无异常发现,可能是因为
对会计对象按经济特征所作的分类,也就是将企业资金运动具体化为若干会计所特有的术语加以表达,称为()。
阅读下面材料,回答问题。材料一“他们没有人拥有铁,也不熟悉,而且没有能力使用它们……在所有这些高岭上,习惯和语言都有一些不同,但是他们都能相互理解,这样的情况非常适合实现让这些人皈依基督教神圣信仰的目标,我想,这是我们最尊贵的国王非常希望的。
某社区发生一起入室盗窃案件,该社区派出所在民工黄某的租房内发现赃物,之后将其拘留。在审讯中黄某始终辩解自己没有实施盗窃,希望公安机关能查明真相。公安机关经多方查证,没有充足证据证明该案为黄某所为,遂将黄某释放。这体现了()。
位于美国密歇根州的珀纳蒙研究所近期出台了一份研究报告,称北美公司的不少离职雇员在离公司时会随身带走属于公司的机密敏感数据。这其中的许多人将会在新公司的工作岗位上为尽快立足而使用这些数据。金融危机引发的经济衰退导致北美许多公司大幅裁员。人们几乎每天在新闻中都
午睡期间,人一旦进入深度睡眠,大脑各中枢的抑制过程明显加强,脑组织中许多毛细血管网会暂时关闭,脑血流量减少,机体的新陈代谢水平明显降低。如果人们在深睡眠阶段中突然醒来,由于大脑皮层中较深的抑制过程不能马上解除,关闭的毛细血管网也不能立即开放,势必造成大脑出
泰州学派
Countrymusicisabout______.
To:AllManagersandDepartmentHeadsSubject:NewCommunicationTrainingProgramClear,friendly,efficientcommunicatio
最新回复
(
0
)