计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
进入题库练习
请打开考生文件夹下的解决方案文件proj3,其中定义了用于表示特定数制的数的模板类Number和表示一天中的时间的类TimeOfDay;程序应当显示:01:02:03.00406:04:06.021但程序中有缺失部分,请按照以下的提示,把缺失部分补充完整:(1)在“//**1** ****found****”的下方是一个定义数据成员seconds的语句,seconds用来表示“秒”。(2)在“//**2** ****found****”的下方是函数advanceSeconds中的一个语句,它使时间前进k秒。(3)在“//**3** ****found****”的下方是函数advance中的一个语句,它确定增加k后n的当前值和进位,并返回进位。例如,若n的当前值是表示时间的55分,增加10分钟后当前值即变为5分,进位为1(即1小时)。注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。填写的内容必须在一行中完成,否则评分将产生错误。//proj3.cpp#include#includeusing namespace std;template//数制为base的数class Number{int n;//存放数的当前值public:Number(int i):n(i){)//i必须小于baseint advance(int k);//当前值增加k个单位int value( )const{return n;}//返回数的当前值},class TimeOfDay{public:Numberhours;//小时(0~23)Numberminutes;//分(0~59)//**1** ****found****_______;//秒(0~59)Numbermilliseconds;//毫秒(0~999)TimeOfDay(int h=0,intm=0,int s=0,int milli=0):hours(h),minuteS(m),seconds(S),milliseconds(milli){}void advanceMillis(int k){advanceSeconds (milliseconds.advance(k));}//前进k毫秒void advanceSeconds(int k)//前进k秒{//**2** ****found****_______;}void advanceMinuteS(int k){advanceHour(minutes.advance(k));}//前进k分钟Vvoid advanceHour(int k){hours.advance(k);}//前进k小时void show( )const{//按“小时:分:秒.毫秒”的格式显示时间int c=cout.fill('0');//将填充字符设置为'0'coutcout.fill(c);//恢复原来的填充字符}};templateint Number::advance(int k){n+=k;//增加k个单位int s=0;//s用来累计进位//**3** ****found****while(n>=base)_______//n到达或超过base即进位return s;//返回进位}int msin( ){TimeOfDay time(1,2,3,4);//初始时间:1小时2分3秒4毫秒time.show( );//显示时间time.advanceHour(5);//前进5小时time.advanceSeconds(122);//前进122秒(2分零2秒)time.advanceMilliS(1017);//前进1017毫秒(1秒零17毫秒)couttime.show( );//显示时间coutreturn0;}
进入题库练习
使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并使程序输出的结果为: TestClass2 TestClass3 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构, 错误的语句在∥********error********的下面。#includeiostreamClass TestClass1{public: virtual Void fun()=0;};class TestClass2:public TestClassl{ ∥********error******** int fun() { using namespace std; cout“TestClass2”endl; }};class TestClass3:public TestClass1{∥********error******** void fun() { ∥********error******** cout“TestClass3”endl; }};void main(){ TestClass1*p; TestClass2 obj 1; TeStClass3 obj 2; P=obj 1; P一fun(); obj 2.fun(); return;}
进入题库练习
进入题库练习
使用VC6打开考生文件夹下的源程序文件modi3.cpp,通过把类Distance定义为类Point的友元类,来实现计算两点之间距离的功能。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)把类CDistance定义为类CPoint的友元类。请在注释//********1********之后添加适当的语句。 (2)定义类CPoint的构造函数,完成给私有数据成员x和y的赋值,并且两个参数的缺省值都为0。请在注释//********2********之后添加适当的语句。 (3)完成类CDistance的成员函数length(PointpPoint,PointqPoint)的定义,并在其中计算点p、q之间的距离,并且返回结果。假设两点之间的距离distance=sqrt((pPoint.x-qPoint.x)*(pPoint.x-qPoint.x)+(pPoint.y-qPoint.y)*(pPoint.y-qPoint.y))。请在注释//********3********之后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。1 #include2 #include3 using namespace std;4 class CPoint5 {6 publiC:7 //********1********89 //定义类Point的构造函数10 //********2********1112 void display() { cout13 private:14 float x,y;15 };16 class CDistance17 {18 public:19 float length(CPoint &p,CPoint &q);20 };21 float CDistance::length(CPointpPoint,CPointqPoint)22 {23 //********3********2425 }26 int main()27 {28 CPoint mPoint(10,10),nPoint(40,50);29 mPoint.display();30 nPoint.display();31 CDistance len;32 cout33 return 0;34 }
进入题库练习
请打开考生文件夹下的解决方案文件proj3,其中包含主程序文件main.cpp和用户定义的头文件Array.h,整个程序包含有类Array的定义和主函数main的定义。请把主程序文件中的Array类的成员函数Contrary()的定义补充完整,经补充后运行程序,得到的输出结果应该是: 5 8 5,4,3,2,1 0,0,8.4,5.6,4.5,3.4,2.3,1.2 注意:只允许在“//*******333*******”和“//*******666*******”之间填写内容,不允许修改其他任何地方的内容。//Array.h#includeiosteeamusing namespace std; templateclass Type,int mclass Array {//数组类public: Array(Type b[],int mm){//构造函数 for(int i=0;im; i++) if(imm)a[i]=b[i]; else a[i]=0 ; } void Contrary();//交换数组a中前后位置对称的元素的值 int Length()const{return m;}//返回数组长度 Type operator[](int i)const{//下标运算符重载为成员函数 if(i0 | | i=m) {cout"下标越界!"endl;exit(1);) return a[i]; }prirate: Type a[m];};void writeToFile(const char*);//不用考虑此语句的作用//main.cpp#include"Array.h"//交换数组a中前后位置对称的元素的值temp2ateclaSS Type,int mvoid ArrayType,m::Contrary(){//补充函数体//*******333*******//*******666*******}int main(){ int s1[5]={1,2,3,4,5}; double s2[6]={1.2,2.3,3.4,4.5,5.6,8.4}; Arrayint,5d1(s1,5); Arraydouble,8d2(s2,6); int i; d1.Contrary();d2.Contrary(); coutd1.Length()"CL2.Length()end!; for(i=0 ; i4 ; i++) coutd1[i]","; coutd1[4]endl; for(i=0;i7 ; i++) coutd2|i]","; coutd2[7]endl; writeToFile(" ");//不用考虑此语句的作用 return 0;}
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj2,该工程中含有一个源程序文件proj2.cpp,请将堆栈类的定义补充完整。使程序的输出结果为: The element of stack are:4 3 2 1 注意:请勿修改主函数main和其他函数中的任何内容,只在横线处编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 t //proj2.cpp 2 #includeiostream 3 using namespace std; 4 const int size=5 ; 5 class Stack; 6 class Item 7 { 8 public: 9 //********found******** 10 Item(const int val):___________ {}//构造函数对item进行初始化 11 private: 12 int item; 13 Item*next; 14 friend class Stack; 15 }; 16 class Stack 17 { 18 public: 19 Stack():top(NULL){} 20 ~Stack(); 21 int Pop(); 22 void Push(const int ); 23i private: 24 Item*top; 25 }; 26 Stack::~Stack() 27 { 28 Item*p=top,*q; 29 while(p!=NULL) 30 { 31 q=p一next ; 32 //********found******** 33 _____________; //释放p所指向的节点 34 p=q; 35 } 36 } 37 int Stack::Pop() 38 { 39 Item*temp ; 40 int ret; 41 //**********found********** 42 ___________; //使temp指向栈顶节点 43 ret=top-item; 44 top=top-next; 45 delete temp; 46 return ret; 47 } 48 void Stack::Push(const intval) 49 { 50 Item*temp=new Item(val); 51 //**********found********** 52 } //使新节点的next指针指向栈顶数据 53 top=temp; 54 ) 55 int main() 56 { 57 Stack s; 58 for(int i=1;iSize;i++) 59 s.Push(i); 60 cout"The element of stack are:"; 61 for(i=1;iSize;i++) 62 couts.Pop()'\t'; 63 return 0; 64 }
进入题库练习
请打开考生文件夹下的解决方案文件proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: Constructor called. The value is 10 Copy constructor called. The value is lO Destructor called. Destructor called. 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#includeiostreamusing namespace std;class MyClass{public://ERROR *******found******* Myclass(int i) {value=i;cout"Constructor called."endl;}//ERROR *******found******* Myclass(const Myclass p) { Value=p.value; cout"Copy constructor called."endl: } void Print() {cout"The value is"valueendl ;)//ERROR *******found******* void ~MyClas s() { cout "Destructor called."endl;}private: int value;};int main(){ MyClass obj1 ; obj1.Print(); MyClass obj2(objl); obj2.Print(); return 0 ;}
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj1,此工程中包含程序文件main.cpp,其中有类Score(“成绩”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:学号:12345678课程:英语总评成绩:85注意:只修改每个“//ERROR****found****”下的一行,不要改动程序中的其他内容。#includeusing namespace std;Class score{public:Score (const char*the_course,const char*the_id,int the_normal,int the_midterm,int the end_of_term):course(the_course),normal(the_normal),midterm(the_midterm),end_of_term(the_end_of_term){//ERROR*******found*******strcpy(the_id,student_id);}const char*getCourse( )const(return course;}//返回课程名称//ERROR*******found*******const char*getID( )const{returnstudent_id;)//返回学号int getNormal( )const{returnnormal;}//返回平时成绩int getMidterm( )const{return midterm;}//返回期中考试成绩int getEndOfTerm( )const{return end_of_term;}//返回期末考试成绩int getFinal( )const;//返回总评成绩private:const char*course;//课程名称char student id[12];//学号int normal;//平时戍绩int midterm;//期中考试成绩int end of term;/期考试成绩};//总评成绩中平时成绩占20%,期中考试占30%,期末考试占50%,最后结果四舍五入为一个整数//ERROR*******found*******int getFinal( )const{return normal*0.2+midterm*0.3+end_of_term*0.5+0.5;}int main( ){char English[ ]="英语";Score score(English,"12345678",68,83,92);coutcoutcoutgetFinal( )return0;}
进入题库练习
请打开考生文件夹下的解决方案文件proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR********found********”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: NUM=0 Value=1 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 1 //proj1.cpp 2 #include iostream 3 using namespace std; 4 class MyClass{ 5 int_i; 6 friend void Tncrement(MyClassf); 7 public: 8 const int;NUM; 9 //ERROR ********found******** 10 MyClass(int i=0){NUH=0; 11 _i=i ; 12 } 13 int GetValue()const{return i; } 14 }; 15 //ERROR ********found******** 16 void Increment;(){f.i++;} 17 int main() 18 19 MyClass obj ; 20 //ERROR ********found******** 21 MyClass::Increment(obj); 22 cout"NUH="obj.NUHendl 23 "Value="obj.GetValue()endl; 24 return 0 ; 25 }
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj2,此工程中包含一个源程序文件main.cpp,其中有“房间”类Room及其派生出的“办公室”类Office的定义,还有主函数main的定义。请在程序中“//****found****”下的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 办公室房间号:308 办公室长度:5.6 办公室宽度:4.8 办公室面积:26.88 办公室所属部门:会计科 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#includeiostreamusing 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(th_room_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 Roomt//“办公室”类 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.theDepartmenI()endl; return 0;}
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj2,该工程中包含一个程序文件main.cpp,其中有坐标点类point、线段类Line和三角形类Triangle的定义,还有main函数的定义。程序中两点间距离的计算是按公式d=实现的,三角形面积的计算是按公式f=实现的,其中s=。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为: Side 1:9.43398 Side 2:5 Side 3:8 area:20 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#irlclude#includeusing rlamespace std;class point{//坐标点类public: const double x,y; Point(double x=0.0,doubley=0.0):x(x),y(y){}// ********found******** double distanceTo(____________)const{//到指定点的距离 return sqrt((x-p.x)*(x—p.x)+(y—p.y)*(y—p.y)); }};class Line{//线段类public: const Point p1,p2 ;//线段的两个端点 // ********found******** Line(Point p1,Point p2):_____________{} double length()const{returnp1.distanceTo(p2);}//线段的长度};class Triangle{//三角形类public:const Point p1,p2,p3;//三角形的三个顶点// ********found********Triangle(__________):p1(p2),p2(p2),p3(p3){}double lengthl()const{//边p1,p2的长度 return Line(p1,p2).length(); } double length2()const{//边p2,p3的长度 return Line(p2,p3).length(); } double length3()const{//边p3,p1的长度 return Line(p3,p1).length(); } double area()const(//三角形面积 // ********found******** double s=___________; return sqrt(s*(s-length1())*(s-length2())*(s-length3())); }};int main(){ Triangle r(Point(0.0,8.0),Point(5.0,0.0),Point(0.0,0.0)); cout"Side 1:"
进入题库练习