首页 > 公务员
题目内容 (请给出正确答案)
[主观题]

有如下程序:#include<iostream>#include<cstring>using namespace std;class XCF{in

有如下程序:

#include<iostream>

#include<cstring>

using namespace std;

class XCF{

int a;

public:

XCF(int aa=O):a(aA){cout<<”1”;}

XCF(XCF&X){a=x.a;cout<<”2”;}

~XCF(){cout<<at}

int Geta(){return at}

};

int main(){

XCF dl(5),d2(d1);

XCF半pd=new XCF(8);

cout<<pd->Geta();

delete pd;

return 0;

}

运行时的输出结果是

A.1215588

B.1218855

C.12185

D.128512

答案
收藏

B
解析:在主函数中XCFd1(5),d2(d1);,d1调用了第一个构造函数,输出1;d2调用了拷贝构造函数,输出2;xcF*pd=IleW XCF’(8);调用了构造函数,输出l;cout<<pd->Geta( );调用了成员函数Geta( ),输出8;delete pd;调用了析构函数,输出8;return 0;,在返回O之前程序会自动调用d1和d2的析构函数,输出55。因此总的输出应该是1218855。

如果结果不匹配,请 联系老师 获取答案
您可能会需要:
您的账号:,可能还需要:
您的账号:
发送账号密码至手机
发送
安装优题宝APP,拍照搜题省时又省心!
更多“有如下程序:#include<iostream>#inclu…”相关的问题
第1题
请写出如下程序的输出结果:#include void Swap( int &a, int & b);void main(){int
请写出如下程序的输出结果:#include void Swap(int &a, int & b);void main(){int

请写出如下程序的输出结果:

#include void Swap(int &a, int & b);void main(){int x(10 ), y(7 );

cout<< "x="<< x<< " y="<< y<< endl;Swap(x , y );cout<< "x="<< x<< " y="<< y<< endl;

}void Swap(int & a, int & b){ int temp; temp = a ; a=b ; b=temp ; }

点击查看答案
第2题
请写出如下程序的输出结果:#include class R{public:R(int r1,int r2) {R1=r1;R2=r2;}void p
请写出如下程序的输出结果:#include class R{public:R(int r1,int r2) {R1=r1;R2=r2;}void p

请写出如下程序的输出结果:

#include class R{public:R(int r1,int r2) {R1=r1;R2=r2;}void print();

void print() const;private:int R1,R2;};void R::print(){cout<< R1<< ":"<< R2<< endl;

}void R::print() const{cout<< R1<< ";"<< R2<< endl;}void main(){R a(5,4);a.print();

const R b(20,52);b.print();}

点击查看答案
第3题
函数search的原型为:char *search(char *str1,char *str2);,其功能是在字符串str1中查找字
函数search的原型为:char *search(char *str1,char *str2);,其功能是在字符串str1中查找字

符串str2第一次出现的位置。测试用主函数如下所示,请编制search函数,并判断整个程序实现的功能。

#include

#include

void main()

{

char *search(char *str1,char *str2);

char *ptr;

char s1[100],s2[100];

cout<< "Input the s1 and s2:"<< endl;

cin>>s1>>s2;

ptr=search(s1,s2);

if(ptr!=NULL)

cout<< "子串第一次出现的位置是:s1["<< ptr-s1<< "]"<< endl;

else

cout<< s2<< "没有出现在"<< s1<< "中。"<< endl;

}

点击查看答案
第4题
‎有以下程序‎#include‎void main()‎{ int a,b,d=25;‏a=d/10%9;‏b=a&&(-1);‏printf("%d,%d/n",a,b);}‎程序运行后的输出结果是()。

A.2,1

B.2,0

C.3,1

D.6,1

点击查看答案
第5题
‎有以下程序‎#include‎void main()‎{int a ;‎scanf("%d",&a);‎if(a >= 0)‎{if

A.-11 is a positive odd number.

B.-11 is a negative odd number.

C.-11 is a positive even number.

D.11 is a negative even number.

点击查看答案
第6题
有以下程序:#include<stdio.h>void fun(char *a,char*B){while(*a=='*')a++;while(*b=*A){b++;a+

有以下程序: #include<stdio.h> void fun(char *a,char*B){while(*a=='*')a++; while(*b=*A){b++;a++;} } main() {char*s="****a*b****",t[80]; fun(s,t);puts(t); } 程序的运行结果是()。

A.*****a*b

B.a*b

C.a*b****

D.ab

点击查看答案
第7题
38) 有以下程序:#include <stdio.h>void fun(char *t,char *s){ while(*t!=0) t++;while((

38) 有以下程序:

#include <stdio.h>

void fun(char *t,char *s)

{ while(*t!=0) t++;

while((*t++=*s++)!=0);

}

main()

{ char ss[10]= " acc " ,aa[10]= " bbxxyy " ;

fun(ss,aa);

printf(" %s,%s\n " ,ss,aa);

}

程序运行结果是

A)accxyy,bbxxyy

B)acc, bbxxyy

C)accxxyy,bbxxyy

D) accbbxxyy,bbxxyy

点击查看答案
第8题
‌有以下程序#include‎void main()‎{int a = 12, b = -34, c = -56, min;‎min = a;if(min > b)‎min = b;‎if(min > c)‎min = c;‎printf("min = %d", min);}输出结果是()。

A.min = 12

B.min = -34

C.-56

D.min = -56

点击查看答案
第9题
从键盘输入你的出生年月,编程输出你出生的月份有多少...

从键盘输入你的出生年月,编程输出你出生的月份有多少天,是什么季节,假设规定3~5月为春季,6~8月为夏季,9~11月为秋季,1、2和12月为冬季。要求程序能够在用户输入非法字符或者非法的年份和月份时输出错误提示信息:"Input error!\n",并结束程序的执行。 要求考虑闰年的情况,已知满足如下条件之一的就是闰年: (1)能被4整除但不能被100整除; (2)能被400整除。 **输入格式要求:"%d, %d" 提示信息:"Input year,month:" **输出天数的格式要求:"%d days\n" **输出季节的格式要求:"The season is spring\n","The season is summer\n","The season is autumn\n","The season is winter\n" 如果输入了非法字符或者年份小于1或者月份不在合法的区间内,则输出"Input error!\n",并结束程序的执行。 程序运行示例如下: Input year,month:2012,2↙ 29 days The season is winter 补全缺少的语句 #include <stdio.h> #include <stdlib.h> int main() { int year, month, n; printf("Input year,month:"); n = scanf("%d, %d", &year, &month); if (____________) { printf("Input error!\n"); exit(0); } if (____________ ) { if (____________ ) printf("29 days\n"); else printf("28 days\n"); } else if (____________ ) printf("30 days\n"); else printf("31 days\n"); if (month >= 3 && month <= 5) printf("the season is spring\n"); else if (month>= 6 && month <= 8) printf("the season is summer\n"); else if (month>= 9 && month <= 11) printf("the season is autumn\n"); else winter\n"); return 0;> A、第一句: n != 2 || year < 1 || month < 1 || month >12 第二句: month == 2 第三句: year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) 第四句:month == 4 || month == 6 || month == 9 || month == 11

B、第一句: n != 2 || year < 1 || month < 1 || month >12 第二句: month = 2 第三句: year % 4 = 0 && year % 100 != 0) || (year % 400 = 0) 第四句:month = 4 || month = 6 || month = 9 || month = 11

C、第一句: n != 2 && year < 1 && month < 1 && month >12 第二句: month == 2 第三句: year % 4 == 0 && year % 100 != 0) || (year % 400 == 0) 第四句:month == 4 && month == 6 && month == 9 && month == 11

D、第一句: n = 2 || year < 1 || month < 1 || month >12 第二句: month = 2 第三句: year % 4 = 0 && year % 100 != 0) || (year % 400 = 0) 第四句:month = 4 || month = 6 || month = 9 || month = 11

点击查看答案
第10题
‏有以下程序‏#include‏void main()‏{int i,s=0;for(i=1;i<10;i+=2)‎s+=i+1;‎printf("%d/n",s);}‏程序运行后的输出结果是()。

A.数1~10的累加和

B.数1~9的累加和

C.数1~9中的奇数之和

D.数1~10中的偶数之和

点击查看答案
第11题
require()和include()区别.require()遇到错误时停止执行程序,include()发出警告后继续执行程序。()
点击查看答案
退出 登录/注册
发送账号至手机
密码将被重置
获取验证码
发送
温馨提示
该问题答案仅针对搜题卡用户开放,请点击购买搜题卡。
马上购买搜题卡
我已购买搜题卡, 登录账号 继续查看答案
重置密码
确认修改