题目内容 (请给出正确答案)
[主观题]

若有以下程序:#include<iostream>using namespace std;int fun(){static int i=0;int s=1;s+=i;i

若有以下程序: #include<iostream> using namespace std; int fun() { static int i=0; int s=1; s+=i; i++; return s; } int main() { int i,a=0; for(i=0;i<5;i++) a+=fun(); cout<<a<<endl; return 0; } 程序运行后,输出的结果是()。

A.20

B.24

C.26

D.15

提问人:网友greenfirefly 发布时间:2022-01-07
参考答案
查看官方参考答案
如搜索结果不匹配,请 联系老师 获取答案
更多“若有以下程序:#include<iostream>using…”相关的问题
第1题
有如下程序

#include

using namespace std;

int i=1;

class Fun{

public;

static int i;

int value(){return i-1}

int value ()const{return i+1;}

};

int Fun;;i=2;

int main(){

int i=3;

Fun Fun1

const Fun fun2;

return 0;

}

若程序的输出结果是:

123

则程序中下划线处遗漏的语句是______。

A.cout<

B.cout<

C.cout<

D.cout$amp;;$br>

点击查看答案
第2题
以下程序的输出结果是【 】。

include <iostream>

using namespace std;

void fun()

{

static int a=0;

a+=2;

cout<<a;

}

int main()

{

int CC;

for(CC=1;cc<4;CC++)

fun();

cout<<end1;

return 0;

}

点击查看答案
第3题
下面程序的运行结果是【 】。

include <iostream>

using namespace std;

void fun(int &a, int b=3)

{

static int i=2;

a = a + b + i;

i = i + a;

}

int main()

{

int x=5, y=2;

fun(x, y);

cout<<x<<",";

fun(x);

cout<<x<<end1;

return 0;

}

点击查看答案
第4题
下面程序的输出结果是【 】。

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;

}

点击查看答案
第5题
下面程序的输出结果是: #include "iostream" using namespace std; int main() { int i=17; while(i>=10) if(--i%4==3) continue; else cout<<"i="<<i--<<endl; return 0;> A、i=16 i=15 i=14 i=13

B、i=16 i=14 i=12

C、i=16 i=14 i=12 i=10

D、i=17 i=15 i=13 i=11

点击查看答案
第6题
已定义类A: class A { private: int x; protected: int y; public: int z; A(int p1, int p2, int p3) { x = p1; y = p2; z = p3; } // 构造函数 }; 再定义派生类B: class B : public A { private: int a; public: // 定义派生类B的构造函数 }; 则下列派生类B的构造函数定义中,正确的是( )。

A、B(int p1, int p2, int p3, int p4) { a = p4; }

B、B(int p1, int p2, int p3, int p4) : A(p1, p2, p3) { a = p4; }

C、B(int p1, int p2, int p3, int p4) { x = p1; y = p2; z = p3; a = p4; }

D、B(int p1, int p2, int p3, int p4) { A(p1, p2, p3); a = p4; }

点击查看答案
第7题
执行以下程序段后,a,b的值为多少?() void swap(int x,int y) { int temp; temp=x; x=y; y=temp; } void main( ) { int a=10,b=20; swap(a,b); Console.WriteLine("a={0} b={1}", a,b); }

A、a=10 b=10

B、a=10 b=20

C、a=20 b=10

D、a=20 b=20

点击查看答案
第8题
阅读下面程序: #include<iostream.h> fun(int a,int b) { int c; c=a+b; return c; } void main() { int x=6,y=7,z=8,r; r=fun((x--,y++,x+y),z--); cout<<r<<endl; } 则该程序的输出结果是()。

A.11

B.20

C.21

D.31

点击查看答案
第9题
已知下列语句中的x和y都是int型变量,其中错误的语句是()。

A.x=y++;

B.x=++y;

C.(x+ y)++

D.++x=y;

点击查看答案
第10题
若有int *x[3]:则以下表述正确的是 ______。

A.x是一个指向具有3个元素的整型数组的指针

B.x是一个指向int型变量的指针

C.x是一个有3个元素的指针数组,每个元素是一个int型指针

D.x是一个数组,该数组的元素是指针x所指向的变量

点击查看答案
账号:
你好,尊敬的用户
复制账号
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改
欢迎分享答案

为鼓励登录用户提交答案,简答题每个月将会抽取一批参与作答的用户给予奖励,具体奖励活动请关注官方微信公众号:简答题

简答题官方微信公众号

警告:系统检测到您的账号存在安全风险

为了保护您的账号安全,请在“简答题”公众号进行验证,点击“官网服务”-“账号验证”后输入验证码“”完成验证,验证成功后方可继续查看答案!

微信搜一搜
简答题
点击打开微信
警告:系统检测到您的账号存在安全风险
抱歉,您的账号因涉嫌违反简答题购买须知被冻结。您可在“简答题”微信公众号中的“官网服务”-“账号解封申请”申请解封,或联系客服
微信搜一搜
简答题
点击打开微信