计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj2,其中有类Point(“点”)、Rectangle(“矩形”)和Circle(“圆”)的定义。在程序所使用的平面坐标系统中,x轴的正方向是水平向右的,Y轴的正方向是竖直向下的。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应该是: ----圆形--------- 圆心=(3,2) 半径=1 面积=3.14159 ----外切矩形------- 左上角=(2,1) 右下角=(4,3) 面积=4 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#includeiostream#includecmathusing namespace std;//平面坐标中的点//本题坐标系统中,x轴的正方向水平向右,y轴的正方向竖直向下。class Point{public: Point(double x=0.0,doubley=0.O):x_(x),y_(y) {} double getX()const{returnx;} double get~()const{returny;} void setX(double x){x=x;} void setY(double y){y=y;}private: double x; //x坐标 double y; //y坐标};//矩形class Rectangle{public: Rectangle(Point p,int w,int h) :point(P),width(w),height(h){} double area() const//矩形面积 { return width*height; } Point topLeft() const //左上角顶点 { return point ; } Point bottomRight()const//右下角顶点(注:y轴正方向竖直向下) {//*********found*********return Point(_____________);}private: Point point;//左上角顶点 double width;//水平边长度 double height;//垂直边长度};//圆形class Circle{public: Circle(Point p,double r) :center(p),tadius(r){} Rectangle boundingBox ( )const;//外切矩形 double area() const//圆形面积 {//*********found********* EetuEn PI__________;)public: static const double PI;//圆周率private: Point center; //圆心 double radius; //半径 }; const double Circle::PI=3.14159; Rectangle Circle::boundingBox ()const { //*********found*********Point pt(___________);int w,h;//*********found********* w=h=_________; return Rectangle(pt,w,h); ) int main() { Point P(3,2); Circle c(p,1); tout"----圆形------------\n"; cout"圆心=("p.getX () ','p.getY() ")\n"; cout "半径 =" 1 endl; cout"面积="c.area()endlendl; Rectangle bb=c.boundingBox(); Point tl=bb.topLeft(); Point br=bb.bottomRight(); cout"----外切矩形-----------\n";cout"左上角=("t1.getX()','t1.getY()")\n"; cout"右下角= ("br.getX() ','br.getY() ")\n"; cout"面积="bb.area()endl; return 0;}
进入题库练习
进入题库练习
请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程中声明的Array是一个表示数组的类。一个Array对象可以包含多个整型元素。A唧的成员说明如下: 成员函数add用于向数组的末尾添加一个元素; 成员函数get用于获取数组中指定位置的元素; 数据成员a表示实际用于存储数据的整型数组; 数据成员size表示数组的容量,数组中的元素个数最多不能超过size; 数据成员num表示当前数组中的元素个数。 SonedA=ay是Array的派生类,表示有序数组。SonedArray重新定义了Array中的add函数,以确保有序数组中的元素始终按照升序排列。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为: 10,9,8,7,6,5,4,3,2,1, 1,2,3,4,5,6,7,8,9,10, 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#includeiostreamusing 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(numsize){//**********found********** num++; } } int get(unsigned int i)const { if(isize) return a[i]; return 0; }protected: int*a; unsigned int Size,num; }; class SortedArray:public Array{ public: //**********found********** SortedArray(uns igned int s):__________{} virtual void add(int e) { if(num=size) return; int i=0,j; while(inum){ if(ea[i])( for(j=num;ji;j--){//**********found********** _________; }//**********found********** _________; break; } i++; } if(i==num) a[i]=e; num++; }};void fun(Arraya){ int i; for(i=10;i=1;i--){ a.add(i); } for(i=0;i10;i++){ couta.get(i)","; } coutendl; } int main() { Array a(10); fun(a); SortedArray sa(10); fun(sa); return 0; }
进入题库练习
请打开考生文件夹下的解决方案文件proj2,其中定义了Component类、Composite类和Leaf类。Component是抽象基类,Composite和Leaf是Component的公有派生类。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: Leaf Node 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#includeiostreamusing namespace std;class Component{public://声明纯虚函数print()//********found********};class Composite:public Component{public://********found******** void setChiid(___________) { m child=child; } virtual void print()const { m chiid-print(); }private: Component*m_chiid; }; class Leaf:public Component{ public: virtual void print()const {//********found******** }};int main(){ Leaf node; Composite comp; comp.setChiid(node); Component*p=comp; p-print(); return 0;}
进入题库练习
请打开考生文件夹下的解决方案文件proj1,该工程中包含程序文件main.cpp,其中有类Foo和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: X=a Y=42 注意:只修改每个“//ERROR *********found*********”下的那一行,不要改动程序中的其他内容。#include iostreamusing namespace std;class Foo{public: Foo(char x){x =x;} char getX()aonst{return x;}public: static int y;private: char x;};//ERROR *********found*********int Foo.y =42 ;int main(int argc, char*arqv[]){//ERROR *********found********* Foo f ;//ERROR *********found********* cout "X = " f.x endl; cout "Y = " f.y endl; return 0 ;}
进入题库练习
进入题库练习
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj1,其中在编辑窗口内显示的主程序文件中定义有类AAA和主函数main。程序文本中位于每行“//ERROR****found****”下面的一行有错误,请加以改正。改正后程序的输出结果应该是:sum=60注意:只修改每个“//ERROR****found****”下面的一行,不要改动程序中的其他任何内容。#includeusing namespace std;class AAA{int a[10];int n;//ERROR*******found*******private:AAA(int aa[ ],int nn):n(nn){//ERROR*******found*******for(int i=0;i}int Geta(int i){return a[i]};};int main( ){int a[6]={2,5,8,10,15,20};AAA x(a,6);int sum=0;//ERROR*******found*******for(int i=0;isum+=x.a[i];coutreturn0;}
进入题库练习
请打开考生文件夹下的解决方案文件proj3,其中该工程中包含定义了用于表示姓名的抽象类Name、表示“先名后姓”的姓名类Namel(名、姓之间用空格隔开)和表示“先姓后名”的姓名类Name2(姓、名之间用逗号隔开);程序应当显示: John Smith Smith,John 但程序中有缺失部分,请按照以下提示,把缺失部分补充完整: (1)在“//**1** ****found****”的下方是函数show中的一个语句,它按先名后姓的格式输出姓名。 (2)在“//**2** ****found****”的下方是函数getWord中的一个语句,它把一个字符序列复制到head所指向的字符空间中,复制从start所指向的字符开始,共复制end-start个字符。 (3)在“//**3** ****found****”的下方是函数createName中的语句,它根据指针P的值决定返回何种对象:如果p为空,直接返回一个Namel对象,否则直接返回一个Name2对象。注意:返回的Name1或Name2对象必须是动态对象,返回的实际是指向它的指针。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。填写的内容必须在一行中完成,否则评分将产生错误。//proj3.cpp#includeiostreamusing namespace std;class Name{protected: char*surname; //姓 char*firstname; //名public: ~Name(){ delete[]surname;delete[]firstname;} virtual void show()=0 ;};class Namel:public Name{public: Namel(const char*name);//**1** *******found*******void show(){___________;}};class Name2:public Name{public: Name2(const char*name); void show() { coutsurname','firstname;}};char*getWord (const char*Start,const char*end){ char*head=new char[end-start+1];//**2** *******found******* for(int i=0;iend-start;i++)__________; head[end-start]='\0'; return head;}Namel::Namel(const char*name){ char*p=strchr(name,''); firstname=getWord(name,p); surname=new char[strlen(p)]; strcpy(surname,p+1);}Name2::Name2(const char*name){ char*p=strchr(name,','); Surname=getWord(name,p); firstname=new char[strlen(p)]; strcpy(firstname,p+1);}Name*createName(const char*s){ char*p=strchr(s,',');//**3** *******found*******if(p)______________;}int main(){ Name*n ; n=createName("John Smith"); n-show();coutendl; delete n; n=createName("Smith,John"); n-show();coutendl; delete n; return 0;}
进入题库练习
使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: This is a greart! Hello Hello 注意:错误的语句在//******error******的下面,修改该语句即可。1 #include2 class CMyClass3 {4 public:5 void display1()6 {7 cout8 }9 void display2()10 {11 //********error********12 char str[5]=''Hello'';13 cout14 }15 //******error******16 void display3(char string)17 {18 //******error******19 cout20 }21 };22 void main()23 {24 CMyClass myclass;25 myclass.display1();26 myclass.display2();27 myclass.display3(''Heiio'');28 }
进入题库练习
进入题库练习
进入题库练习
进入题库练习
请打开考生文件夹下的解决方案文件proj1,该工程中包含程序文件main.cpp,其中有类Door(“门”)和主函数main的定义。程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 打开503号门…门是锁着的,打不开。 打开503号门的锁…锁开了。 打开503号门…门打开了。 打开503号门…门是开着的,无须再开门。 锁上503号门…先关门…门锁上了。 注意:只修改每个“//ERROR ********found********”下的那一行,不要改动程序中的其他内容。#includeiostreamusing namespace std;class Door{ int num; //门号 bool closed; //true表示门关着 bool locked; //true表示门锁着public: Door(int num){//ERROR ********found******** num=this-num; closed=locked=true; } bool isClosed()corlst{return closed;}//门关着时返回true,否则返回false bool isOpened()const{return !closed;}//门开着时返回true,否则返回false bool isLocked()const{return locked;}//门锁着时返回true,否则返回false bool isUnlocked()COlISt(return!locked;}//门未锁时返回true,否则返回false void open(){ //开门 toutendl"打开"num"号门…"; //ERROR ****found**** if(closed) cout"门是开着的,无须再开门。”; elSe if(locked) cout"门是锁着的,打不开。"; else{ closed=false; tout;"门打开了。"; } } void close(){ //关门 coutendl"关上"num"号门…"; if(closed) tout"门是关着的,无须再关门。"; else{ closed=true; cout"门关上了。"; } }//ERROR ********found******** void lock()const{ //锁门 coutendl"锁上"num"号门…"; if(locked) tout"门是锁着的,无须再锁门。"; else{ if(!closecl){ cout"先关门…"; c10sed=true; } locked=true; cout"门锁上了。"; } } void unlock(){ //开锁 coutendl"开"num"号门的锁…"; if(!locked) cout"门没有上锁,无须再开锁。”; else{ locked=false; tOUt"锁开了。"; } } }; int main(){ Door door(503); door.open(); door.unlock(); door.open(); door.open(); door.lock(); return 0;}
进入题库练习
进入题库练习