计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。函数MergeAndSort(int s[],int e[],int a[],int m,int n)实现将两个数组合并。这两个数组已经有序,按照由小到大的顺序排列。 例如: e[]={1,3,5,6},m是数组e的长度,即为4。 a[]={2,4,5,7,11,13},n是数组a的长度,即为6。 则执行的结果为:s[]={1,2,3,4,5,6,7,11,13} 补充函数fun(int s[],im e[],int a[],int m,int n),使之实现上述要求。 注意:请勿改动主函数。 #include void MergeAndSort(int s[], int e[],int a[],int m,int n) { } int main() { int data[20],i; int a[]={1,3,5,6}; int b[]=(2,4,5,7,11,13}; cout<<"a[]="; for(i=0;i<4;i++) cout<
问答题使用VC6打开考生文件夹下的源程序文件modi3.epp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义CMyTime的私有成员函数m year、m month 类型为 int, 请在注释∥********1********后添加适当的语句。 (2)补充完成CMyTime的构造函数,完成对m.year m_month、 的赋值, 请在注释∥********2********后添加适当的语句。 (3)完成print()的输出,请在注释∥********3********后添加适当的语句。输出格式如下: Current Time year:XX month:XX 注意:XX表示两位0~9的数字,如Current Timeyear:08 month:04。 (4)完成对month的增加函数AddMonth(int m),请在注释∥********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。{}include<iostream.h>class CMyTime{private: ∥********1********public: CMyTime(int year,int month) { ∥********2******** } void di splay() { char yearChar[3]; char monthChar[3]; yearChar[0]=(m year%1 0 0)/1 0+‘0’; yearChar[1]=(m year%10)+‘0’; monthChar[0]=(m month%1 0 0)/1 0+‘0’; monthChar[1 j=(m month%1 0)+‘0’;∥********3******** cout<<“Current Time”<<” year: “<<yearChar<<” month:”<<monthChar<<end1; } void AddMonth(int m) { m month=m month一1+m; ∥********4******** m month=m month%12+1; } void AddYear(int n) { m_year=m year+n: }};int main(){ CMyTime myTime(200 6,11); myTime.AddMonth(5); myTime.display(); myTime.AddYear(1); myTime.di splay(); return 0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,此工程包含一个源程序文件proj1.cpp。文件中将表示数组元素个数的常量Size定义为4,并用int类型对类模板进行了实例化。文件中位于每个注释“//ERROR****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:1234注意:模板参数名用T。只修改注释“//ERROR********found********”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>usingnamespacestd;//将数组元素个数Size定义为4//ERROR********found********constintSize;template<typenameT>classMyClass{public:MyClass(T*P){for(inti=0;i<Size;i++)array[i]=p[i];}voidPrint();private:Tarray[Size];};template<typenameT>//ERROR********found********voidMyClass::Print(){for(inti=0;i<Size;i++)cout<<array[i]<<'\t';}intmain(){intintArray[Size]={1,2,3,4};//ERROR********found********MyClass<double>obj(intArray);obj.Print(),cout<<end1;return0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程中声明的Array是一个表示数组的类。一个Array对象可以包含多个整型元素。Array的成员说明如下:成员函数add用于向数组的末尾添加一个元素;成员函数get用于获取数组中指定位置的元素;数据成员a表示实际用于存储数据的整型数组;数据成员size表示数组的容量,数组中的元素个数最多不能超过size; 数据成员num表示当前数组中的元素个数。 $ortedArray是Array的派生类,表示有序数组。SortedArray重新定义了Array中的add函数,以确保有序数组中的元素始终按照升序排列。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为:10,9,8,7,6,5,4,3,2,1,l,2,3,4,5,6,7,8,9,10,注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iostream>using namespace std;class Array{public: Array(unsigned int S) {size=S;num=0;a=new int[s];}virtual—Array(){delete[]a; )virtual void add(int e){if(num<size){//**********found********** num++;} ) int get(unsigned int i)const {if(i<Size)return a[i];return 0;}protected: int*a; unsigned int size,num; }; class SortedArray:public Array{ public: //********** found********** SortedArray(unsigned int s) :___________{} virtual void add(int e) {if(num>=size)return;int i=0,j;while(i<num){if(e<a[i]){for(j=num;j>i;j—){//**********found********** ——;: }//**********found********** ——: break;}i++;}if(i=num)a[i]=e;num++;} }; void fun(Array&a) { int i; for(i=10;i>=1;i—一){a.add(i);}for(i=0;i<1 0;i++){cout<<a.get(i)<<“,”;}cout<<endl; } int main() { Array a(10); fun(a); SortedArray sa(10); fun(sa); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2。此工程中包含一个源程序文件main.cpp,其中有“房间”类Room及其派生出的“办公室”类Office的定义,还有主函数main的定义。请在程序中“//****found****”下的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 办公室房间号:308 办公室长度:5.6 办公室宽度:4.8 办公室面积:26.88 办公室所属部门:会计科 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include<iostream> using namespace std; class Room{ //“房间”类 int room_no;//房间号 double length;//房间长度(m) double width;//房间宽度(m) public: Room(int the_room_no,double the_length,double the_width):room_no(the_loom_no),length(the_length),width(the_width){} int theRoomNo()const{return room_no;} //返回房间号 double theLength()const{return length;} //返回房间长度 double theWidth()const{return width;} //返回房间宽度 //**********found********** double theArea()const{__________}//返回房间面积(矩形面积) }; class Office:public Room{//“办公室”类 char*depart;//所属部门 public: Office(int the_room_no,double the_length,double the_width,const char*the_depart) //**********found********** ::____________{ depart=new char[strlen(the_depart)+1]; //**********found********** strcpy(________); } ~Office(){delete[]depart;} const char * theDepartment()const{return depart;}//返回所属部门 }; int main(){ //**********found********** Office__________; cout<<"办公室房间号:"<<an_office.theRoomNo()<<endl <<"办公室长度:"<<an_office.theLength()<<endl <<"办公室宽度:"<<an_office.theWidth()<<endl <<"办公室面积:"<<an_office.theArea()<<endl <<"办公室所属部门:"<<an_office.theDepartment()<<endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完成。 (1)定义私有数据成员leftPoint、topPoint、rightPoint、bottomPoint,分别用于表示矩形左上角及右下角的点的坐标,它们都是double型的数据。请在注释∥********1********之后添加适当的语句。 (2)完成默认构造函数CRect的定义,指定缺省实参为0,都是double型的数据。请在注释∥********2********之后添加适当的语句。 (3)定义函数体为空的析构函数。请在注释∥********3********之后添加适当的语句。 (4)在main()函数中定义CRect类的实例reet2,并把rectl的值赋给rect2。请在注释∥********4********之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include Class CRect { private: ∥********1******** public: ∥********2******** ∥********3******** void SetPoints(double, double,double,double); void SetLeftPoint(double m) (1eftPoint=m;) void SetRightPoint(double m) {rightPoint=m;) void SetToppoint(double m) {topPoint=m;) void SetBottomPoint (double m){bottomPoint=m;) void Display(); ); CRect::CRect(double 1,double t,double r,double b) { leftPoint=1;topPoint=t ; rightPoint=r;bottomPoint =b ; } void CRect::SetPointS(double 1,double t,double r,double b) { leftPoint=1 ; topPoint=t; rightPoint=r;bottompoint =b ; } void CRect::Di splay() { cout(<”left—top point iS (”<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: This is a greart! Hello Hello 注意:错误的语句在//********error********的下面,修改该语句即可。#include<iostream.h>class CMyClass{public: void displayl() { cout<<"This is great!"<<endl; } void display2() { //********error******** char str[5]="Hello"; cout<<str<<endl; ) //********error******** void display3(char string) { //********error******** cout<<string<<endl }};void main(){ CMyClass myclass; myclass.displayl(); myclass.display2(); myclass.display3("Hello");}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: i=5 i=10 i=15 i=20 注意:错误的语句在//********error********的下面,修改该语句即可。#include<iostream.h>class CMyClass{public: template<clas S T> void func(T x,T y) { /********error******** T i=0; if(x>=i) { i=i+x; } else ( i=i+y; } cout<<"i="<<i<<endl; }};void main(){ CMyClass t; t.func(5,0); /********error********/ t.func(68,(char)i); float i=10.0; /********error********/ t.func(i,1); t.func(5,5);}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中有整数栈类IntList、顺序栈类SeqList和链接栈类LinkList的定义。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 4 6 3 1 8 4 6 3 1 8 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动//“****found****”。#include<iostream>using namespace std;class IntStack{ //整数栈类public:virtual VOid push(int)=0;//入栈virtual int pop()=0;//出栈并返回出栈元素 virtual int topElement()const=0;//返回栈顶元素。但不出栈 virtual bool isEmpty()oonst=0;//判断是否栈空};class SeqStack:public IntStack{ int data[100]; //存放栈元素的数组 int top; //栈顶元素的下标public: //**********found********** SeqStack():_______()//把top初始化为一1表示栈空 void push(int n){data[++top]=n;) //**********found********** int pop(){return________;} int topElement()const{return data[top];} bool isEmpty()const{return top=一1;) }; struct Node{ int data; Node*next; }; class LinkStack:public IntStack{ Node*top;public://********** found**********LinkStack():_________{)//把top初始化为NULL表示栈空 void push(int n){ Node*P=new Node; P->data=n; //********** found********** ________; top=P; } int pop(){ int d=top->data;; top=top->next; return d; } int topElement()const{return top 一>data;) bool isEmpty()const{return top== NULL;) }, void pushData(IntStack pushData(stl);pop Data(stl); cout<<end1; LinkStack st2;pushData(st2);pop Data(st2); cout<<end1; return 0;}
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件3.cpp,要求编写一个CMyShape类,含有求面积、周长等的纯虚函数,然后编写一个CRectangle类和CCircle类继承CMyShape,并实现求面积、周长的两个函数。在main函数中测试得到下面的结果:   在CMyShape类构造函数内   在CCircle类构造函数内   在CMyShape类构造函数内   在CReetangle类构造函数内   myCircle:Area=314.159Girth=62.8319   myRectangle:Area=900Girth=120   具体要求如下:   (1)定义求面积的纯虚函数,请在注释1后添加适当的语句。   (2)定义求周长的纯虚函数,请在注释2后添加适当的语句。   (3)请在注释3和注释4后添加适当的语句。   注意:除在指定位置添加语句之外,不要改动程序中的其他内容。   试题程序:   #include   #inelude      #definePI3.1415926   classCMyPoint   {   public:   intX,y;   CMyPoint(inttx,intty):x(tx),y(ty){}   };   classCMyShape   {   public:   CMyShape(){cout{{"在CMyShape类构造函数内"   <  //********1********   //********2********   protected:   };   classCCircle:publicCMyShape   {   public:   CCircle(CMyPointi,doublej):CMyShape(),arc-   Center(i),radius(j)   {   cout<<"在CCircle类构造函数内"<  }   doubleGetArea()   {   returnPI*radius*radius:   }   doubleGetGirth()   {   return2*PI*radius:   }   private:   CMyPointarcCenter;   doubleradius;   };   classCRectangle:publicCMyShape   {   public:   CRectangle(CMyPointIt,CMyPomtrb):leftTop(it),   rightBottom(rb),CMyShape()   {   cout<<"在CRectangle类构造函数内"<  }   doubleGetArea()   {   intwidth=abs(rightBottom.X-leftTop.x);   intheight=abs(rightBottom.y-leftTop.y);   returnwidth*height:   }   doubleGetGirth()   {   intwidth=abs(rightBottom.x-leftTop.x);   intheight=abs(rightBottom.y-leftTop.y);   return2*(width+height):   }   private:   CMyPointleftTop,rightBottom;   };   voidmain()   {   CMyShape*myShape=NULL;   CCircle*myCircle=newCCircle(CMyPoint(5,5),10);   CRectangle*myRectangle=newCRectangle(CMy—Point(0,O),CMyPoint(30,30));   //********3********   cout<<"myCircle:"<<"Area="<
进入题库练习
问答题请编写函数fun(),该函数的功能是将M行N列的二维数组中的数据,按列的顺序依次放到一维数组中。 例如:二维数组中的数据为 33333333 44444444 55555555 则一维数组中的内容应是 334455334455334455334455。 注意:部分源程序以存在文件test_2.cpp中。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 文件test39_2.cpp的内容如下: #include<stdio.h> #include<iostream.h> void fun(int(*s) [10],int *b, int *n,int mm,int nn) void main( ) int w[10][10]=33,33,33,33,44,44,44,44,55,55,55,55,i,j; int a[100]=0, n=0; cout<<"The matrix:/n" for(i=0; i<3; i++) for(j=0; j<4; j++ cout<<w[i] [j]; cout<<endl; fun(w, a, cout<<"The A array:/n"; for(i=0; i<n; i++) cout<<a[i]; cout<<"/n/n";
进入题库练习
问答题使用VC6打开考生文件夹proj2下的工程proj2,其中有两个类:一是销售类(sale),用于表示按照一件商品的基本价格进行销售;另一个是打折销售类(DiscountSale).用于表示在基本价格基础上按一个折扣比例进行销售。DiscountSale类继承了sale类。类的土要数据成员的含义和成员函数的功能要求在程序注释中有说明。请在程序中的横线处填写适当的代码,然后删除横线,完成程序的功能。此程序的正确输出结果应为:Discount item is cheaper.Saving is0.1注意:只能在横线处填写适当的代码,不要改动程序中的其他内容。#include<iostream>using namespace std;class Sale{public:Sale();//默认构造函数,将price初始化为0Sale(double the_price);//构造函数,用the_price初始化pricevirtual double bill()const;//返回当前商品的价格(基本价)double savings(const Sale&other)const;//返回参数other所引用的对象比当前对象便宜的差价protected:double price;//商品的基本价格(不打折的价格)};Sale::Sale():price(0){}Sale::Sale(double the_price):price(the_price){}double Sale::bill()const{return price;}double Sale::savings(const Sale&other)const{//**********found**********______________;//返回当前对象价格比other贵多少的差价}class DiscountSale:public Sale//打折销售类继承销售类{public:DiscountSale();//默认构造函数,将discount初始化为0DiscountSale(double the_price,double the_discount);//构造函数,the_price是基本价格;the_discount是折扣百分比virtual double bill()const;//返回本商品销售价格(即打折以后的实际售价,覆盖了基类的bill函数)protected:double discount;//折扣百分比。例如降价至原价的70%,此成员值应为70};DiscountSaie::DiscountSale():discount(0){}DiscountSale::DiscountSale(double the_price,double the_discount):Sale(the_price),discount(the_discount){}double DiscountSale::bill()const{doubte fraction=discount/100;//**********found**********______________;//返回本对象打折以后的实际售价}bool operator<(const Sale&first,const Sale& second)}//**********found**********______________;//判断是否first价格低于second价格}int main(){Sale simple(10.00);DiscountSale discount(11.00,90);if(discount<simple){cout<<"Discount item is cheaper.\n"://**********found**********//这里输出购买discount比购买simple节省多少钱cout<<"Saving is"<<______________<<endl;}elsecout<<"Discount item is not cheaper.\n":return0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中定义了vehicle类,并派生出motorcar类和bicycle类。然后以motorcar和bicycle作为基类,再派生出motocycle类。要求将vehicle作为虚基类,避免二义性问题。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:Avehicleisrunning!Avehiclehasstopped!Abicycleisrunning!Abicyclehasstopped!Amotorcarisnmning!Amotocycleisrunning!注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iostream.h>classvehicle{private:intMaxSpeed;intWeight;public:vehicle():MaxSpeed(0),Weight(0){}vehicle(intmax_speed,intweight):MaxSpeed(max_speed),Weight(weight){}//**********found**********________Run(){cout<<"AvehicleiSrunning!"<<end1;}//**********found**********________Stop(){cout<<"Avehiclehasstopped!"<<end1;}};classbicycle:virtualpublicvehicle{private:intHeight;public:bicycle():Height(0){}bicycle(intmax_speed,intweight,intheight):vehicle(max_speed,weight),Height(height){};voidRun(){cout<<"Abicycleisrunning!"<<end1;}voidStop(){cout<<”Abicyclehasstopped!”<<end1;));classmotorcar:virtualpublicvehicle{private:intSeatNum;public:motorcar():SeatNum(0){}motorcar(intmaxspeed,intweight,intseat_num)//**********found**********:________{}voidRun(){cout<<"Amotorcarisrunning!"<<end1;}voidStop(){cout<<"Amotorcarhasstopped!"<<end1;}};//**********found**********classmOtOrcycle:________{public:motorcycle(){}motorcycle(intmax_speed,intweight,intheight,intseet_num):bicycle(max_speed,weight,height),motorcar(max_speed,weight,seet_num){};~motorcycle(){};voidRun(){cout<<"Amotorcycleisrunning!"<<end1;}voidStop(){cout<<"AmotOrcyclehasstopped!"<<end1;}};intmain(){vehicle*ptr;vehiclea;bicycleb;motorcarc;motorcycled;a.Run();a.Stop();b.Run();b.Stop();ptr=&c;ptr->Run();ptr=&d;ptr->Run(),return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为: TestClass1 TestClass2 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>#include<assert.h>Struct TestClass0{ //********error******** virtual void fun();};class TestClass1:publicTeStelass0{ void fun() {cout<<"TestClass1"<<end1; }};class TestClass2:publicTestClass0{ void fun() { cout<<"TestClass2"<<end1; }};void main(){ TestClass0* p; TestClass1 obj1; TestClass2 obj2; //********error******** p=* obj1; P->fun(); //********error******** p=*obj2; p->fun(); return;}
进入题库练习
问答题使用VC6打开下的源程序文件modi3.cpp,阅读下列程序说明和代码,功能如下:从屏幕输入数字,然后由大到小插入指定的链中。当输入0时,表示输出的数据已经输入完成,然后把数据打印到屏幕,然后释放内存。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)在父节点的Next中保存新插入的节点的指针,请在注释//********1********后添加适当的语句。(2)把pNext的子节点赋给pNext本身,请在注释//********2********后添加适当的语句。(3)判定p的子节点不为空,如果不为空,则打印p其中的数据到屏幕,请在注释//********3********后添加适当的语句。(4)用temp1保存动态申请内存节点的链表头,请在注释//********4********后添加适当的语句。注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>classTestClass{public:TestClass(intdata=0){this->data=data;this->next=NULL;};intdata;TestClass*next;};voidInsert(TestClass*p,intdata){TestClass*temp=newTestClass(data);TestClass*pParent=p;TestClass*pNext=p->next;while(pNext){if(data>pNext->data){//********1********temp->next=pNext;return;}Else{pParent=pNext;//********2********}}if(pNext==NULL){pParent->next=temp;return;}}voidprintf(TestClass*p){//********3********while(){;p=p->next;}}voidDelete(TestClass*p){//********4********TestClass*temp1=;TestClass*temp2;while(temp1!=NULL){temp2=temp1->next;deletetemp1;temp1=temp2;}}voidmain(){inti=0;TestClasshead;do{intdata;cout"请输入一个数字:"endl;cindata;if(data==0)break;Insert(}while(1);printf(Delete(return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出: number1=4.8 number2=93.6 number3=0.9 PRODUCT=404.352 注意:错误的语句在//********error********”的下面。修改该语句即可。其他的语句不能修改。#include<iostream>using namespace std;int main(){ double number1=4.8,number2=93.6,number3=0.9; //********error******** Product=number1*number2*number3; //********error******** cout<<"number1="<<number1< '\t'<< "number2="<<number2<<'\t'; //********error******** cout<<"number3="<<number3<<'\t'; cout<<"PRODUCT="<<product<<endl; return 0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下 的工程proj2。此工程中包含一个源程序文件main.epp,其中有“房间”类Room及其派生出的“办公室”类Office的定义,还有主函数main的定义。请在程序中“//****found****”下的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:办公室房间号:308办公室长度:5.6办公室宽度:4.8办公室面积:26.88办公室所属部门:会计科注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<10stream>usingnamespacestd;classRoom{//“房间”类introomno;//房间号doublelength;//房间长度(m)doublewidth;//房间宽度(m)public:Room(intthe_room_no,doublethe_length,doublethe_width):room_no(the_room_no),length(the_length),width(the_width){}inttheRoomNo()const{returnroom_no;}//返回房间号doubletheLength()const{returnlength;}//返回房间长度doubletheWidth()const{returnwidth;}//返回房间宽度//**********found**********doubletheArea()const{________)//返回房间面积(矩形面积)},classOffice:publicRoom{//“办公室”类char*depart;//所属部门public:Office(intthe_room_no,doublethe_length,doublethe_width,constchar*thedepart)//**********found**********:________{depart:newchar[strlen(thedepart)+1];//**********found**********strcpy(________);}~Office(){delete[]depart;}constchar*theDepartment()const{returndepart;}//返回所属部门};intmain(){//**********found**********Office________;cout<<"办公室房问号:"<<anoffice.theRoomNo()<<end1<<"办公室长度:"<<an_office.theLength()<<end1<<--办公室宽度:"<<an_office.theWidth()<<end1<<"办公室面积:"<an_office.theArea()<<end1<<"办公室所属部门:"<<an_office.theDepartment()<<end1;return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: m=-10 n=-10 p=0 q=-10 z=A 注意:错误的语句在//"error"的下面,修改该语句即可。#include<iostream.h>Void main(){ double m=10 ; float n=10; bool p=1; int q=10 ; char z='a'; m=一m; //********error******** n=~n; //********error******** p=-p; //********error******** q=~q; z=z一32; cout<<"m="<<m<<endl; cout<<"n="<<n<<endl; cout<<"p="<<p<<endl; cout<<"q="<<q<<endl; cout<<"z="<<z<<endl: return;}
进入题库练习
问答题使用VC6打开 proj1下的工程proj1,其中定义了一个CD类。程序中位于每个//ERROR**********found**********下的语句行有错误,请加以更正,不得修改程序的其他部分。更正后程序的输出应该是: 歌唱祖国 30 义勇军进行曲 95 注意:只能修改每个//ERROR**********found**********下的那一行,不要改动程序中的其他内容。 #include<iostream> #include<cstring> using namespace std; class CD { char name[20]; int number; public: void init(char*aa,int bb) { //ERROR*****found***** name=aa; number=bb; } char*getName(){ //ERROR*****found***** return*name; } int getNumber(){return number;) void output(){ //ERROR*****found***** cout<<name[20]<<""<<number<<endl; } }; void main() { CD dx,dy; dx.init("歌唱祖国",30); dy.init("义勇军进行曲",3*dx.getNumber()+5); dx.output(); dy.output(); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)完成类Rect的构造函数,实现对变量left、right、top、bottom的初始化,缺省值都为0,请在注释//********1********后添加适当的语句。(2)完成类Rectangle的构造函数,请在注释//********2********后添加适当的语句。(3)完成计算矩形对角线长度函数Diagonal(),请在注释//********3********后添加适当的语句。(4)完成计算周长函数Girth(),请在注释//********4********后添加适当的语句。程序输出:50140注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>#include<cmath>class Rectangle{public:int left,right,top,bottom;//********1********{left=1;right=r;top=t;bottom=b;}//********2********{left=rc.left;right=rc.right;top=rc.top;bottom=rc.bottom;}float Diagonal(){//********3********return}int Girth(){//********4********return}};int main(){Rectangle rect(20,50,40,80);Rectangle rect2(rect);cout<<rect2.Diagonal()<<endl;cout<<rect2.Girth()<<endl;return0;}
进入题库练习