




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
公共基础知识及C++语言程序设计(90100)分)一、选择题((1)~(35)270分A)、B)、C)、D)四个选项中,只有一个选项是正确的,请将正确选项涂写在答题 (3)在一棵二叉树上第5层的结点数最多是 goto对 (12)判断字符型变量ch是否为大写英文字母,应使用表达式A)ch>='A'& B)ch<='A'C) D)ch>='A'&&已知下列语句中的x和y都是int B) C) D)intn;cin>>n; casecase2:cout<<casecase4:cout<<'2';break;default:cout<<'3';} #include<iostream>usingnamespacestd;intmain(){chara[]=" char*ptr=a;while{if(*ptr>='a'&&*ptr<=cout<<char(*ptr+'A'-'a');elsecout<<*ptr;}return}A O, B o,C O, D o,int B)intC)int D)intvoidFun(intx=0,intvoidFun(intx,intvoidFun(intx,intvoidFun(intx=0,int已知程序中已经定义了函数test,其原型是inttest(intintint);chardoubleintfloattest(int,int,float=3.5F);inti=0;voidfun() staticinti=1;}}int{ return0;} (20)已知函数f的原型是:voidf(int*along&b);变量v1、v2的定义是:intv1;longv2;,正确的A)f(v1, B)f(v1,C)f(&v1,v2); Df(&v1,&v2);class{则执行语句MyClassab[2*p[2]; A是类B的友元,那么类B也是类A如果函数fun()被说明为类A的友元,那么在fun()中可以类A的私有成A是类B的友元,那么类A的所有成员函数都是类Bnew和delete是C++语言中专门用于动态内存分配和释放的函数当动态分配内存失败时,系统会立刻,因此一定要慎用newusingnamespaceclass{MyClass(intn){number=MyClass(MyClass&other){intMyClassfun(MyClass{MyClasstemp(p);returntemp;}int{MyClassobj1(10),obj2(0);MyClassobj3(obj1);return} 在C++ virtualvoid B)voidC)virtualintvf(int); Dvirtualvoidvf(intVolumeoperator-(double,template<classT1,classtemplate<classT1;classT2>ofstreamif(...)cout<<"OK";elsecout<<后,如果文件打开成功显示“OK”,否则就显示“F厶n。”。由此可知,上面ifA)outfilefail()或outfile B)outfile.good()或!outfileC)outfile.good()或outfile D)outfile.fail()或!outfile(32)C++流中重载的运算符>>是一个() classPoint{Point(intx=0,inty=0){_.x=x;_.y=y;}voidMove(intxOff,intyOff){_x+=xOff;_.y+=yOff;}voidPrint()const{cout<<'('<<_x<<','<<_y<<')'<<endl;}int_x,Pointpt;constPointpt;Pointpt;pt.Move(l,constPointptpt.Move(l2);class{intchargender,char*phone;MyClass():id(0),gender('#'),phone(NULL){}MyClass(intno,charge='#',char*ph=NULl.){id=no;gende=ge;phone=ph;MyClass MyClassmyObj(12,MyClassmyObj(12);#include<iostream>usingnamespacestd;classComplex{Complex(doubler=0,doublei=0):re(r),im(i){}doublereal()const{returnre;}doubleimag()const{returnim;}Complexoperator+(Complexc){returnComplex(re+cre,im+c.im);}doublere,int{Complexa=Complex(l,1)+Complex(5);cout<<a.real()<<'+'<<a.imag()<<'i'<<endl;return0;} B) C) D)二、填空题(230分算法的复杂度主要包括 数据的逻辑结构在计算机空间中的存放形式称为数据的 若按功能划分,软件测试的方法通常分为白盒测试方法和[3]如果一个工人可管理多个设备,而一个设备只被一个工人管理,则实体“工人”与实体“设备之间存在[4][5]设有定义语句:inta=12a*=2+3的运算结果是[6]从实现的角度划分,C++所支持的两种多态性分别是 (8)将—个函数为一个类的友元函数必须使用关键字[8] (9)请按下面注释的提示,将类B的构造函数定义补充完整。classA{inta;A(intaa=0){a=aa;classB:publicA{intb;//用aa初始化基类A,用aa+1初始化类对象成员B(int [9]{b=aa+2;下列程序的输出结果是[10]#include<iostream>usingnamespacestd;intmain(){inti=int&r=i;r=7;cout<<i<<endl;return0;}下列程序的输出结果是[11]#include<iostream>usingnamespacestd;classTest{Test(){cnt++;staticintCount(){returncnt;}staticint t=int{cout<<Test::Count0<<'';Testtl,t2;Test*pT3=newTest;Test*pT4=newTest;cout<<Test::Count0<<'';deletepT4;deletecout<<Test::Count()<<endl;return0;}下面是用来计算n的阶乘的递归函数,请将该函数的定义补充完整。(unsignedfact(unsignedn){if(n<=}
return [12 下列程序的输出结果是[13]#include<iostream>usingnamespacestd;template<tytenameT>Tfun(Ta,Tb){return(a<=b)?:b;}intmain(){cout<<fun(3,6)<<','<<fun(3.14F,6.28F)<<endl;return0;}与成员表达式p->name等价的表达式是[14]下列程序的输出结果是[15]#include<iostream>usingnamespacestd;classbase{intbase(intx){n=virtualvoidset(intm){n=m;cout<<n<<'classderiveA:publicbase{deriveA(intx):base(x){voidset(mtm){n+=m;cout<<n<<'classderiveB:publicbase[deriveB(intx):base(x){voidset(intm){n+=m;cout<<n<<'int{deriveAdl(1);deriveBd2(3);base*pbase;pbase=&dl;pbase=&d2;return}20049公共基础知识及C++语言程序设计选择题((1)—(35)270分(1) (2) (3) (4) (5)(6)(7)(8)(9)二、填空题(230分(1)[1](2)[2]结构或物理结构或物理结(3)[3]黑盒或黑箱(4)[4]一对多或1对多或I:M或I:N(M、N大小写均可)(5)[5]投影(6)[6](7)[7](8)[8](9)[9]A(aa),c(aa+1)或c(aa+1),A(aa)(10)[10]7 (13)[13](14)[14](*p)(15)[15]20103月计算机等级考试二级C++一、选择题(270分A)、B)、C)、D)四个选项中,只有一个选项是正确的。请将正确选项填涂在答题对长度为n的有序链表进行查找,情况下需要的比较次数为对长度为n的有序链表进行对分查找,情况下需要的比较次数为(nlog2n)数据流程图(DFD图)是C)阶有两个关系R和T则由关系R得到关系T并若MyClassMyClassMyClass*c3=newMyClass;MyClass&c4=c1;4Decr&operator--Decroperator--(friendDecr&operator--frlendDecroperator--1在C++中,cin在下列字符中,不允许作为C++标识符的是365是一个int3.1415926是一个double若x和y是程序中的两个整型变量,则下列ifif(x==0)y=1;elseif(x==0)theny=1elseif(x==0)y=1elseifx==0y=1;else要定义整型数组x,使之包括初值为OintintstaticintintA)<返回类型>int要定义一个变量p,使之类MyClass的一个对象,正确的定义语句MyClassMyClassp=newMyClass&p=newMyClassa,&p=a;classXX{doublex1;doublex2;doublex3;doubley1;doubley2;double1D)重载类型转换运算符时不需要返回类型D)showpoint(27)4个函数,其中具有隐含thisintfun1();intfun2();friendintfun3();staticintusingnamespacestd;classTest{Testfun(Test&u){Testt=u;returnt;}intmain(){Testx,y;x=fun(yreturn0;}usingnamespacestd;classA{A(inti=0):r1(i){voidprint(){cout<<'E’<<R1<<'-';}<voidprint()const{cout<<'C'<<R1*R1<<'-';}<p>voidprint(intx){cout<<'P'<<R1*R1*R1<<'-';}<p>intintmain(){Aa1;constAa2(4);return0;}下列代码了3个 classStudent:public classUndergraduate:Student{}; 是类Undergraduate的基Undergraduate从类Student类Student是 usingnamespacestd;ClassBase{intclassDerived:publicBase{intintDerivedobj12(2,3);retuen0;}下面是类ShapeclassShape{virtualvoid下列关于ShapeShapeShape类Shape中的Draw函数有语句“Shapes;”能够建立Shape的一个对象MyClockoperator+MyClockoperator+MyClockoperator+MyClockoperator+①ios_base::app③ios_base::inusingnamespacestd;ClassB{B(intxx):x(xx){++cout;x+=10;}virtualvoidshow()conststaticintcount;intclassD:publicB{D(intxx,intyy):B(xx),y(yy){++count;y+=100;}virtualvoidshow()constintintB::count=0;intmain(){B*ptr=newD(10,20);deleteptr;return0;}二、填空题(230分一个队列的初始状态为空。现将元素A,B,C,D,E,F,5,4,3,2,1依次入队,然后再依次退队,则元素退队的顺序为【1】。设某循环队列的容量为50,如果头指针front=45(指向队头元素的前一位置)rear=10(指向队尾元素)234模式选课可定义为:选课(学号,【5】,成绩)。若x和yx=5;y=6;y+=x--后,x+y6int ++;时,do后面的循环体语句i++7intXfun(int*a,intn){intx=*a;for(int*pa=a+1;pa<>if(*pa>x)x=*pa;returnx;}int后,通过表达式Xfun(x,5)8intXfun(intx){int{intx=10;y+=x;}returnx+y;}通过表达式Xfun(5)9Xcs是一个类,该类中一个成员函数的原型为“Xcs*abc();”,则在类外定义时对应的函数头为【10】。Date定义的对象FirstDay201011classDate{Date(【11):year(y),month(m),day(d){//usingnamespacestd;classBook{Book(char*str)【12voidPrintInfo()cout<<TITLE<<ENDLp>charclassMyBook:publicBook{MyBook(char*s1,char*s2="【13】virtualvoidPrintInfo()cout<<TITLE<<"是"OWNER<<"的书"<<ENDL;p>charintBook*prt=newMyBook("飘");return}在有理数类Rational中重载运算符<<,以便按a/q形式输出。请将<<运算符函数的classRational{Rational(intaa,int):a(aa),q){friend【14operator<<(ostream&outRational{return(out<<X.A<<'p}intintsquare(intn){returndoublesquare(doublen){return1520074月计算机等级考试C++一、选择题(270分下列各题、B、、D)四个选项中,只有一个选项是正确的。请将正确选项涂写在答题卡A)各模块应包括尽量多的功能B)各模块的规模应尽量大A)B)C)D)某二叉树中有n2A)n+1B)n-1C)2nB)C)D)在E-R图中,B)C)D)为了取代C中带参数的宏,在C++中使用A)B)C)D)友元函数A)类定义中包括数据成员和函数成员的B)C)D)templateclassTTsouare(Tx)(retumx*x)基中T是B)C)D)使用输入输出操作符setw,B)C)D)下列字符串中,不可以用作C++标识符的是A)y_2006B) TESTHC)RetumD)switchlong、doubleintB)long、float、intC)int、double、longD)int、float、longfor(inti=50;I>1;—i)cout<<”*”A)48B)49C)50D)51inti=0,j=1;int&r=i;//①r=j;//②int*p=&i;//③*p=&r;A)④B)③C)②D)voidfunc(inta,int&b){a++;intx=0,y=1则变量x和yA)01B)11C)02D)1usingnamespacestd;classA{staticinta;voidA(inta=2)intA:;a=0Aobj;Int{}A)0B)1C)2B!=template<typenameT>Tabs(Tx){returnx<0–x:x;}B)templateclass<T>Tabs(Tx){retumx<0-x;x;}C)templateT<classT.>abs(Tx){retumx<0-x;x;}D)templateTabs(Tx){returmx<0-x;x;}在语句cin>>data;中,cin是A)C++的关键字B)类名C)对象名D)函数名usingnamespacestd;classtest{inta;test(inta){cout<<a<<endl;}test(consttest&_test){cout<<”copy}int}testA(3)C)copyconstructordstructorclassMyClass{MyClass()MyClassusingnamespacestd;classpoint{staticintnumber;imtpoint::number=0;voidmain(){{point*ptr_point=newpoint{3};}}A)3B)4C)6usingnamespacestd;classBase{inta,b;Bace(intx,inty){a=x;}clsaaDerived:publicBase{intc,d;Derived(intx,inty,intz,intm):Base(x,y){c=z;d=m;}Voidshow(){cout<<c<<’,’d<<endl;}int{BaseB1(50,50),*pb;DerivedDI(10,20,30,40);Return0;}A)10,20B)30,40C)20,30usingnamespacestd;classA{A(inti){x=iintxclass{B(inti):A(i+10){x=ivouddispb(){dispa();cout<<x<,endl;}Intint{Bb(2);retum0:}A)10,2B)12,10C)12,2usingnamespacestd;classBase{virtualvoidf(){cout<<”f0+”;}voidg(){cout<<”g0+”;}classDerived:public{voidf(){cout<<”f+”;}voidg(){cout<<”g+”;}int{Derivedp->f();p-return}A)f+g+B)f0+g+C)f+g0+下面程序中对一维坐标点类Pointusingnamespacestd;classpoint{point(intvaI)point&printoperator++(int){pointold=*this,++(*this);retumold;}intGetX()const{retumx;}intint{pointa(10);}usingnamespacestd;intmain(){charstr[100],*p;cout<<”pleaseinputastring:”;for(inti=0;*p!=”\0”;p++,i++);cout<<i<<endl;retum}abcdefgA)7B)12C)13usingnamespacestd:classSample{friendlongfun(Samples);Sample(longalonglongfun(Sample{if(s.x<2)retuma);}int{intfor(inti=0;i<6;i++){sum+=fun(Sample(i);)}retum}A)120B)16C)154二、填空题(230分721在数据库系统中,实现各种数据管理体制功能的软件称为【3】软件生命周期可分为多个阶段一般分为定义阶段开发和阶段编码和测试属于【4C++中只有两个逻辑常量:true6若要指针变量p所指向的数据,应使用表达式【7】intfn(double5.278classMA{intvalue;MA(intMA9如下类定义中包含了构造函数和拷贝数的原型请在横线处写正确的内容使拷贝构造函数的完整。ClassmyClass{Intdata:MyClass(intvalue)MyClass(const【10anotherObject)}usingnamespacestd;clsaaCA{classCB;privateCA{intintmain(){CAa;CB}12usingnamespacestd;classDA{intk;DA(intx=1):kintDADA*p=newDA[2];}14C++1520074月计算机等级考试C++考试答案6-16-21-26-30-1、23、47、12、13、114、152007年9计算机等级考试二级笔试试卷C++语言程序设(90100分一、选择题(270分下列A、B、C、D四个选项重,只有一个选项是正确的,请将正确选项涂写在答题卡相A程 B程序和文C算法加数据结 D程序、数据与相关文档的完整集A发现错 B改正错C改善软件的性 D验证软件的正确A对象的继 B对象的多C对象的封 D对象的分A程序的效率第一,清晰第 B程序的可读性C程序中要有必要的注 D输入数据前要有提示信BCDDA B C DCDCDauto,extem,register,static这四个关键字中的一个来说明变量的A B C Dpublicprotectedpublic成员在派生类中Apublic和 Bpublic和Cprotected和 Dprotected和下列运算符函数中肯定不属于类FunNumberDintoperator–A对象模板和函数模 B对象模板和类模C函数模板和类模 D变量模板和对象模(16)如果调用C++ABC只能借助于cin和coutD中不属于C++ABCDAunsignedlongint和 Bsignedshortint和Bunsignedshort和 Dshortint和(19)Aswitch语句中的caseBifCD(20)语句的int*p=&k定义于指针P,于这个语句等效的语句序列是Aint*p;p=&k Bint*p;p=kCint*p;*p=&k Dint*p;*p=kABCDIntf1();Staticintf2();ClassMA{Intf3();Staticintf4();在所描述的函数中,具有隐含的thisA B C DA共有成员和保护成 B共有成C私有成 D保护成BABCA1234 B******1234C**********1234 D1234******#include<iostrcam>Usingnamespacestd;Classmyclass{Staticintgetcount(){returncount;}StaticintIntMyClass::count=0;Intmain(){Myclassobj;MyClass*ptr=newMyClass;Deleteptr;}A B C DA B C Dval=10 #include<iostream>Usingnamespacestd;Classpart{Part(intIntClasswhole{Whole(intx,inty,intz=0):p2(x),p1(y),val(z){cout<<val;}PartIntIntWholeobj(1,2,3);}A B C(30)有如下程序:#include<iostream>Usingnamespacestd;Classbase{Base(intClassderived:publicbase{BaseIntDerived}A B C DClasssBDoublevarl;ClassD:publicB{已知obj是类D的对象,下列语句中不成员控制的权限的Aobj.fun1(); Bobj.var1; Cobj.fun2(); Dobjfun3();Usingnamespacesid;Classbase{Voidoutput(){cout<<1;}Virtualvoidprint(){cout<<B;}Classderived:publicbase{IntBase*passnewderived;Deleteptr;}A B C DAmyclassBmyclassCmyclassDmyclassoperator*(myclass,(35)#include<iostream>Usingnamespacestd:ClassB{ClassD:publicB{Voidfun2(B&ref){ref.show();}Voidfun3(Bb){b.show();}IntBb,*p=newD;Dd;}A B C D软件需求规格说明书应具有完整性、无性、正确性、可验证性、可修改性等特征,最重
在E-R图中,矩形属 在有定义语句:inta=3,b=2,c=1;则表达式a<b?a:b的值 执行下列语句后,变量sum的值是 Intsum=0;For(intj=I;j<=I;j++)For(intj=I;j<=I;j++)IntStaticint-6;return}则在某程序中第二次执行函数用语句f();时,函数f的返回值是 Usingnamespacestd;Classmyclass{}Int Classsample{}请将如下程序补充完整,使得输出结果为bbaa#include<iostream>Usingnamespace ClassB:publicA{IntmainB*p=newB;Deletep;}请将下列栈类stackClassstack{Int //intInttop; //新元素itemInt If(top==99) }IntIf(top<0) }1-21-31-voidirtualdisplay()==0;20089月计算机等级考试二级C++笔试试题一、选择题(270分一个栈的初始状态为空。现将元素1、2、3、4、5、A、B、C、D、E依次入栈,然后再(B (D(C (A(D控制 (BA)N-S B)DFD图(数据流图C)PAD 一致 (B一对 (C B)文件系统阶 D)二个阶段相(10)R、STRST BCABC 13m13 35由关系R和S通过运算得到关系T,则所使用的运算为(D C) (AA)voidf1(intx); B)voidf2(int*x);C)voidf3(constint*x);D)void(C在一个派生类的成员函数中,试图调用其基类的成员函数“voidf();”,但无法通过编译。(A(BC)B)it、dube样的型修符来模数模板中的关键字class都可以用关键字typename替(B (D (Aconstinta;B)constinta=10;C)constint*point=0;constint*point=newusingnamespacestd;intmain(){intfor(inti=0;i<6;i+=3){for(intj=i;j<6;}return0;}(D (A B)charmyString=" C)charmyString[11]=" D)charmyString[12]=" o-World!";若已经了函数原型“voidfun(inta,doubleb=0.0);”,则下列重载函数中正确的(A)voidfun(inta=90,doubleb=0.0);B)intfun(inta,doubleB);C)voidfun(doublea,intB);D)boolfun(inta,doubleb=0.0);usingnamespacestd;classSample{intSampletemp[2],*pTemp[2];return0;}(B (A D)(BValueoperator+(Value);C)Valueoperator*(int);D)Valueoperator/(Value);(DA)template<typenameT>Tfun(Tx){returnx;}B)template<typenameT>Tfun(Tx,intn){returnx*n;}C)template<classT>Tfun(T*p){return*p;}D)template<classT>TclassA{Tn;};(B类 usingnamespacestd;classMyClass{MyClass(inti=0){cout<<1;}MyClass(constMyClass&x){cout<<2;}MyClass&operator=(constMyClass&x){cout<<3;intMyClassobj1(1),obj2(2),obj3(obj1);return0:}(A usingnamespacestd;classMyClass{MyClass(intx):val(x){}voidSet(intx){val=x;}voidPrint()const{cout<<"val="<<val<<'\t';}intintconstMyClassobj1(10);MyClassobj2(20);obj1.Print();//语句1obj2.Printobj1.Set(20);obj2.Set(30);return}(CA)语句 B)语句C)语句 D)语句(B私 B)公 C)保 (D (A (C(C C)operator>=(a,b)D)operator>=(b,a)当使用ofstream(A)iosbase::in(B 二、填空题(230分A 按照软件测试的一般步骤,集成测试应在单元软件工程三要素包括方法、工具和过程,其中,过程支持软件开发的各个环节的控制括。 X计、_逻辑Y物理设 括。在二维表中,元组的分量当使用关键字voida中有n个元素,下列语句将数组a中从下标x1开始的k个元素移动到从下标x2开始的k个元素中,其中0<=x1<x2<n,x2+k<n,请将下列语句补充完整。for(inti=x1+k-1;i>=x1;i--)usingnamespaceintfun1(intx){return++x;}intfun2(int&x){return++x;}intmain(){intx=1,y=2;y=fun1(fun2(x));return}usingnamespacestd;classpumpkin{staticvoidtotal_count(){}staticintintpumpkin::count=0;intmain(){pumpkinpl[10];return0;}这个程序的输出结果是10pumpkin(s)intFun(intn){if(n<=1)return1;elsereturnn*Fun(n-}FunnclassSample{voidSetData(intSampledataSample::data=data//}private:int有如下类定义,请将SampleclassSample{~Sample(){if(p)deletep;)Sample(constSample&p=new}voidSetData(intdata){p=newint(data);}重载加法运算符“+”,其函数名是operator_usingnamespacestd;classWages工资”类doublebase;//基本工资doublebonus;//奖金doubletax;//税金Wages(doubleCBase,doubleCBonus,doubleCTax):base(CBase),bonus(CBonus),;//double}intretun0;}程序的输出结果是usingnamespacestd;classPet{charname[10];Pet(char*name){strcpy(this->name,name);}constchar*getName()const{returnname;}virtualvoidclassDog:publicPet{classCat:publicPet{int *pet2=newCat("吉米");return}程序的输出结果是20089C++笔试试卷参考答案(1)B(2)D(3)C(4)A(5)D(6)B()A(8)()C(0)D(1))(17B(18)D(19)A(20)(21C)(27C(28B(29(30(31A)(32)C(33)(3)B(5)C)elsereturnn*Fun(n-p=newint;(13)operator2009年9月计算机二级笔试一、选择题(1-10,21-402分,11-201分N-SE-R在E-R有三个关系R,S,和T如下:ABCa12b21c31SABCd32TABCA12B21C31D32其中关系T由关系R和SFAFB,若要把这两个函数定义在同一个文件中,则A)FAFB之前classBB{intclassintxdata;XX(intn=0):xdata(n){classYY:publicXX{intydata;YY(intm=0,intn=0):XX(m),ydata(n){A)运算符函数的名称总是以operator为前缀A)模板形参表必须在关键字template之后B)模板形参表必须用括弧()括起来可以用class可以用typename下列字符串可以用作C++标识符的是C)test-20093的是A)enumtest{RED,YELLOW,BLUE,BLACK};B)enumtestREDYELLOW=4BLUEBLACK};C)enumtestRED=-1YELLOW,BLUEBLACK};D)enumtestREDYELLOW=6BLUEinti=1;while(1){if(i==10)break;if(i%2==0)cout<<'*';}已知数组arrintarr[5]=2的是A)cout<<*arr+1<<endl;B)cout<<*(arr+1)<<endl;C)cout<<arr[1]<<endl;D)cout<<*arr<<endl;计算斐波那契数列第nIntfib(intif(n==0)return1;elseif(n==1)return2;elsereturnfib(n-1)+fib(n-}Sample是一个类,执行下面语句后,调用SampleSamplea[2],*p=newSample;C)“classB:virtualpublicA”说明类B为虚基类template<typenameT1,typenameT2classA;A)template<classT1,classT2>classA;template<classT1,typenameT2>classA;C)template<typenameT1,classT2>classA;D)template<typenameT1,T2>classA;下列关于C++流的描述中,错误的是A)cout>>'A'表达式可输出字符A以ios_base::out#include<iostream>usingnamespacestd;classToy{Toy(char*_n){strcpy(name,_n);~Toy(){count--;char*GetName(){returnname;}staticintgetCount(){returncount;}charname[10];staticintintmail(){return}usingnamespacestd;classA{A(inti):rl(i){voidprint(){cout<<'e'<<r1<<'-voidprint()const{cout<<'C'<<r1*r1<<'-';}intintA return0;}usingnamespacestd;className{charname[20]; }Name(char*fname)){ }intNamenames[3]={Name(“张三”),Name(“李四”)};Return0;}usingnamespacestd;AA(){cout<<'1';classBB:publicAA{intk;BB():k(0){cout<<'2';BB(intn):k(n){}intmain(){BBb(4),return} usingnamespacestd;classC1{~C1(){cout<<1;ClassC2:publicc1{~c2(){cout<<2;intmain(){C2cb2;C1*cb1;return0;} usingnamespaceclassPublication{//物charname[30];}constchar*getName()const{returnname;virtualconstchar*getType()constreturn未知类型classBookpublicPublication{书类Book(char*name):virtualconstchar*getType()constreturn书voidshowPublication(Publication&p){}intBookbook("人生");return0;} Usingnamespacestd;intmain(){ints[]={123,for(inti=0;i<2;i++){cout<<s[i]<<endl;}return0;}classA{char*a;A(char*aa){//把aa所指字符串拷贝到a所指向的空 }~A(){deleteA)neschar[strlen(aa)+1] D)newchar[sizeof(aa)-1]二、填空题(2分,30分)(1)5231的结点,则该二叉树中共有【1】个结点。5231的结点,则该二叉树中共有【1】个结点。程序流程图中的菱形框表示的是【2】。软件开发过程主要分为需求分析、设计、编码与测试四个阶段,其中【3】阶段产生“软“可选课程”的联系为【4】。(5基本信息一般包括号等其中可以作为主关键字的是【5】若表达式(x+(y-z)*(m/n))+3中的变量均为double6For(inti=50;i>20;i-=2)7利用表达式a[i]可以int型数组a中下标为i的元素。在执行了语句int*p=a;后,利用指针p也可该元素,相应的表达式是【8】。voidreverse(int*a,intsize){if(size<2)return;intk=a[0];reverse(a+1,【9}类Sample的构造函数将形参data赋值给数据成员data。请将类定义补充完整。classSample{Sample(intdata=0);Int}classSample{Staticint将静态数据成员data011“图形”Shape中定义了纯虚函数CalArea(),“三角形”TriangleShape,请将Triangle类中的CalArea函数补充完整。classShape{virtualint}classTriangle:publicShape{Triangle{ints,inth}:side(s),height(h)【12returnside*height/2intside;intheight;#include<iostream>usingnamespacestd;classGrandChild{GrandChild(){strcpy(name,"Unknown");}constchar*getName()const{returnname;}virtualchar*getAddress()const=0;charclassGrandSon:publicGrandChild{GrandSon{char*name}Char*getAddress()const{returnintGrandChild*gs=newdeletegs;return}13相应的逻辑值。程序的输出结果为:AfterSorting:Happy #include<iostream>#include<string>usingnamespacestd;classWord{Word(strings):str(s){}stringgetStr(){returnstr;}【14constreturnstr<w.str);friendostream&operator<<(ostream&output,constWord{output<<w.str;returnoutput;}stringIntWordw1("Happy"),w2(" Cout<<"Aftersorting:";if(w1<w2)cout<<w1<<''<<w2;elsecout<<w2<<''<<w1;return}请将下列模板类Datatemplate<typenameT>classData{voidput(Tv){val=v;【15get()//返回数据成员val{returnval;}T2009年9月计算机等级考试二级C++笔试参考答案(1)C(2)B(3)D(4)A(6)A(7)C(8)B(9)C intSample::data=intCalArea(size,height)(13)Unknown住在(14)booloperator<(Wordw)20103月计算机等级考试二级C++一、选择题(270分A)、B)、C)、D)四个选项中,只有一个选项是正确的。请将正确选项填涂在答题对长度为n的有序链表进行查找,情况下需要的比较次数为对长度为n的有序链表进行对分查找,情况下需要的比较次数为(nlog2n)数据流程图(DFD图)是C)阶E-R图来描述信息结构但不涉及信息在计算机中的表示,它属于数据有两个关系R和T则由关系R得到关系T并若MyClassMyClassMyClass*c3=newMyClass;MyClass&c4=c1;4Decr&operator--Decroperator--(friendDecr&operator--frlendDecroperator--1在C++中,cin在下列字符中,不允许作为C++标识符的是365是一个int3.1415926是一个double若x和y是程序中的两个整型变量,则下列ifif(x==0)y=1;elseif(x==0)theny=1elseif(x==0)y=1elseifx==0y=1;else要定义整型数组x,使之包括初值为OintintstaticintintA)<返回类型>int要定义一个变量p,使之类MyClass的一个对象,正确的定义语句My
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024-2025学年高中历史第2单元工业文明的崛起和对中国的冲击第7课新航路的开辟练习岳麓版必修2
- 2024-2025学年高中物理第二章恒定电流第8节多用电表的原理课时训练含解析新人教版选修3-1
- 2024年高中语文第四单元第14课一名物理学家的教育历程课时优案1含解析新人教版必修3
- 2024-2025学年高中物理第四章第5节电磁感应现象的两类情况课后达标能力提升练习含解析新人教版选修3-2
- 电平坑扒炉行业市场发展及发展趋势与投资战略研究报告
- 广东瓷砖项目申请报告范文模板
- 2025年中国茶叶批发行业发展趋势预测及投资战略研究报告
- 2025年中国振动球磨机行业市场供需格局及投资规划建议报告
- 豆乳项目可行性研究报告
- 公路勘察设计行业市场全景监测及投资战略咨询报告
- 货物学 课件全套 孔月红 项目1-8:货物与货物学概述-集装箱货物
- 2024-2025学年洛阳市老城区三年级数学第一学期期末经典试题含解析
- 2024年02月全国2024中国建设银行远程智能银行中心客服代表定向招考笔试历年参考题库附带答案详解
- 双线大桥连续梁刚构专项施工方案及方法
- 美容院前台接待流程
- 中小学食堂财务培训
- 国药现代笔试
- 医疗器械市场部年度规划
- 《商务沟通-策略、方法与案例》课件 第七章 自我沟通
- 按键精灵脚本编写方法
- 节约集约建设用地标准 DG-TJ08-2422-2023
评论
0/150
提交评论