计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开 下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: i=5 i=10 i=15 i=20 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> class CMyClass { public: template<class 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)1); float i=10.0; //******error****** t.func (i,1); t.func (5,5); }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中声明的CDeepCopy是一个用于表示矩阵的类。请编写这个类的赋值运算符成员函数0perator=,以实现深层复制。 要求: 补充编制的内容写在“//************333************”与“//****************666*************”之间。不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //CDeepCopy.h #include #include using namespace std; class CDeepCopy { public: int n;//动态数组的元素个数 int *p;//动态数组首地址 CDeepCopy(int); ~CDeepCopy(); CDeepCopy&operator=(const CDeepCopy&r);//赋值运算符函数 }; void writeToFile(char}); //main.cpp #include”CDeepCopy.h” CDeepCopy::一CDeepCopy(){delete[]P;} CDeepCopy::CDeepCopy(int k){n=k;p=new int[n];}//构造函数实现 CDeepCopy&CDeepCopy::0perator=(const CDeepCopy&r)//赋值运算符函数实现 { //***********333********* //***********666*********** } int main() { CDeepCopy a(2),d(3); a.p[O]=1;d.p[O]=666;//对象a,d数组元素的赋值 { CDeepCopy b(3);//调用赋值运算符函数 a.p[O]=88;b=a; cout<
进入题库练习
问答题基本操作 请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,程序中位于每个"// ERROR ****found****"之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: fruit1 是苹果吗? true fruit1 是梨吗? false fruit2 是苹果吗? true fruit2 是梨吗? False 注意:只修改"/ ERROR****found****"的下一行语句,不要改动程序中的其他内容。 #include using namespace std; class Fruits{ //水果类 public: Fruits(char *the_name, float the_price); // ERROR **********found********** void ~Fruits() {} bool isFruit(char *name)const; //判断是否是参数所指定的水果 private: char name[50]; //水果名称 float price; //水果价格 }; Fruits::Fruits(char *the_name, float the_price){ // ERROR **********found********** strcpy(the_name,name); price = the_price; } bool Fruits::isFruit(char *name)const{ // ERROR **********found********** return strcmp(name,name)==0; } int main(){ Fruits fruit1("苹果",3.00); Fruits fruit2("梨",2.50); cout << boolalpha; cout << "fruit1 是苹果吗? " << fruit1.isFruit("苹果") << endl; cout << "fruit1 是梨吗? " << fruit1.isFruit("梨") << endl; cout << "fruit2 是苹果吗? " << fruit1.isFruit("苹果") << endl; cout << "fruit2 是梨吗? " << fruit1.isFruit("梨") << endl; return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生目录proj3下的工程文件proj3,此工程包含一个源程序文件proj3.cpp,其中定义了用于表示二维向量的类MyVector;程序应当显示(6,8)。但程序中有缺失部分,请按照以下提示,把缺失部分补充完整: (1)在“//** 1** *****found****”的下方是构造函数的定义,它用参数提供的坐标对x和y进行初始化。 (2)在“//**2** ****found****”的下方是减法运算符函数定义中的一条语句。两个二维向量相减生成另一个二维向量:其X坐标等于两向量X坐标之差,其Y坐标等于两向量Y坐标之差。 (3)在“//**3** ****found****”的下方,语句的功能是使变量v3获得新值,它等于向量v1与向量v2之和。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。//proj 3.cpp#include<iostream>using std::ostream;using std::cout;using std::endl;class MyVector{ //表示二维向量的类double X;//x坐标值double y; //Y坐标值public:MyVector(double i=0.0,double j=0.0); //构造函数 MyVector operator+(MyVector j); //重载运算符+ friend MyVector operator一(MyVec—tor i,MyVector j); //重载运算符一 friend ostream //**1** **********found********** ___________(double i,double j):X(i), Y(j){) MyVector MyVector::operator+(MMVecor j){ return MyVector(x+j.X,Y+j.y); } MyVector operator一(MyVector i, MyVector J) {//**2** ***********found***********return MyVector(_______); } ostream&operator<<(ostream&OS, MyVector V){ OS<<’(’<<v.X<<’,’<<v.Y<<’)’;//输出向量v的坐标 return OS; } int main() { MyVector vl(2,3),v2(4,5),v3; //**3** **********found********** v3=__________; cout<<v3<<end1; return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj2下的工程proj2,该工程中含有一个源程序文件proj2.cpp,其中定义了CharShape类、Triangle类和Rectangle类。 CharShape是一个抽象基类,它表示由字符组成的图形(简称字符图形),纯虚函数Show用于显示不同字符图形的相同操作接口。Triangle和Rectangle是CharShape的派生类,它们分别用于表示字符三角形和字符矩形,并且都定义了成员函数Show,用于实现各自的显示操作。程序的正确输出结果应为: * *** ***** ******* ######## ######## ######## 请阅读程序,分析输出结果,然后根据以下要求在横线处填写适当的代码并删除横线。 (1)将Triangle类的成员函数Show补充完整,使字符三角形的显示符合输出结果。 (2)将Rectangle类的成员函数Show补充完整,使字符矩形的显示符合输出结果。 (3)为类外函数fun添加合适的形参。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“// ****found****”。 // proj2.cpp #include <iostream> using namespace std; class CharShape { public: CharShape(char ch) : _ch(ch) {}; virtual void Show() = 0; protected: char _ch; //组成图形的字符 }; class Triangle : public CharShape { public: Triangle (char ch, int r) : CharShape(ch), _rows(r) {} void Show(); private: int _rows; //行数 }; class Rectangle: public CharShape { public: Rectangle (char ch, int r, int c) : CharShape (ch), _rows(r), _cols(c) {} void Show (); private : int _rows, _cols; //行数和列数 }; void Triangle::Show() //输出字符组成的三角形 { for (int i = 1; i < = _rows; i ++) { // ********found******** for (int j = 1; j < =______; j ++) cout << _ch; cout << endl; } } void Rectangle::Show() //输出字符组成的矩形 { // ********found******** for (int i = 1; i < =______; i++) { // ********found******** for (int j = 1; j < =______; j++) cout << _ch; cout << endl; } } // ********found******** 为fun函数添加形参 void fun (______) {cs. Show();} int main() { Triangle tri ("*", 4); Rectangle rect("#", 3, 8); fun(tri); fun(rect); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,该工程中包含程序文件main.cpp,其中有类Door(“门”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 打开503号门…门是锁着的,打不开。 打开503号门的锁…锁开了。 打开503号门…门打开了。 打开503号门…门是开着的,无须再开门。 锁上503号门…先关门…门锁上了。 注意:只修改每个“//ERROR**********found**********”下的那一行,不要改动程序中的其他内容。 #include<iostream> using namespaee std; class Door{ int num;//门号 bool closed;//true表示门关着 bool locked;//true表示门锁着 public: Door(int num){ //ERROR**********found********** num=this->hum; closed=locked=true; } bool isClosed()const{return closed;} //门关着时返回true,否则返回false bool isOpened()const{return!closed;} //门开着时返回true,否则返回false bool isLocked()const{return locked;} //门锁着时返回true,否则返回false bool isUnlocked()const{return!locked;} //门未锁时返回true,否则返回false void open(){ //开门 cout<<endl<<"打开"<<num<<"号门…"; //ERROR**********found********** if(closed) cout<<"门是开着的,无须再开门。"; else if(10cked) cout<<"门是锁着的,打不开。"; else{ closed=false: cout<<"门打开了。"; } } void dose(){ //关门 cout<<endl<<"关上"<<num<<"号门…"; if(closed) cout<<"门是关着的,无须再关门。"; else{ closed=true: cout<<"门关上了。"; } } //ERROR**********found********** void lock()const{//锁门 cout<<endl<<"锁上"<<num<<"号门…"; if(locked) cout<<"门是锁着的,无须再锁门。"; else{ if(!dosed){ cout<<"先关门…"; closed=true; } locked=true; cout<<"门锁上了。"; } } void unlock(){ //开锁 tout<<endl<<"开"<<num<<"号门的锁…"; if(!locked) cout<<"门没有上锁,无须再开锁。"; else{ locked=false; cout<<"锁开了。"; } } }; int main(){ Door door(503); door.open(); door.unlock(); door.open(); door.open(); door.lock(); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的工程test42_3。此工程包含—个test42_3.cpp,其中定义了类Cpolygon、COutput和CTriangle,其中CTriangle类由Cpolygon和COutput类public派生,但三个类的定义并不完整。请按要求完成下列操作,将程序补充完整。 (1)定义类CPolygon的保护数据成员width和height,它们都是int型的数据。请在注释“//**1**”之后添加适当的语句。 (2)完成类CPolygon的成员函数set_values(int a,int b),使参数a和b分别赋值给保护数据成员width和height,请在注释“//**2**”之后添加适当的语句。 (3)完成类Coutput的成员函数output(int)的定义,将传入的参数为血型的i输出到屏幕并换行,请在注释“//**3**”之后添加适当的语句。 (4)完成派生类CTriangle的声明,它由Cpolygon和COutput类public派生,请在注释“//**4**”之后添加适当的语句。 源程序文件test42_3.cpp清单如下: #include <iostream.h> class CPolygon protected: // ** 1 ** public: void set_values(int a, int b) // ** 2 ** ; class COutput public: void output(int i); ; void COutput::output(int i) // ** 3 ** // ** 4 ** public: int area (void) return (width * height / 2); int main () CTriangle trgl; trgl.set_values (4,5); trgl.output (trgl.area()); return 0;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。此工程中包括类Point、函数fun和主函数main。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Thepointis(0,1)Thepointis(3,5)注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>usingnamespacestd;classPoint{public://ERROR*********found*********Point(intx=0,inty):x_(x),y_(y){}//ERROR*********found*********voidmove(IntxOff,intyOff)const{x_+=xOff;y_+=yOff;}voidprint()const{tout<<"Thepointis("<<x_<<','<<y_<<')'<<end1;}private:intx_,y_;};voidfun(Point*p){//ERROR*********fOUnd*********p.print();}intmain(){Pointp1,p2(2,1);p1.print();p2.move(1,4);fun(&p2);return0;}
进入题库练习
问答题简单应用题 编写函数fun(),它的功能是求n以内(不包括n)同时能被3与7整除的所有自然数之和的平方根s,并做为函数值返回。 例如:n为1000时,函数值应为s=153.909064。 注意:部分源程序给出如下。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #include #include #include doublefun(intn) { main() { clrscr(); printf("s=%f\n",fun(1000)); }
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。阅读下列函数说明和代码,补充空出的代码。使sum(int n)能计算所有n的因子之和(不包括1和自身)。 注意:不能修改程序的其他部分,只能补充sum函数。 试题程序: #include<iostream.h> int sum(int n) void main() cout<<sum(10)<<end1; cout<<sum(200)<<end1; cout<<sum(400)<<end1; return;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2。此工程中包含一个源程序文件main.cpp,其中有“书”类Book及其派生出的“教材”类TeachingMaterial的定义,还有主函数main的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义和函数定义。该程序的正确输出结果应为:教材名:C++语言程序设计页数:299作者:张三相关课程:面向对象的程序设计注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iostream>usingnamespacestd;classBook{//“书”类char*title;//书名intnum_pages;//页数char*writer;//作者姓名public://**********found**********Book(constchar*thetitle,intpages,constchar*thewriter):________{title=newchar[strlen(thetitle)+1];strcpy(title,thetitle);//**********found**********strcpy(writer,thewriter);}~Book(){delete[]title;delete[]writer;}intnumOfPages()const{returnnumpages;}//返回书的页数constchar*theTitle()const{returntitle,t}//返回书名constchar*theWriter()const{returnwriter;}//返回作者名};classTeachingMaterial:publicBook{//“教材”类char*course;public:TeachingMaterial(constchar*thetitle,intpages,constchar*thewriter,constchar*thecourse)//***+******found**********:________{course=newchar[strlen(thecourse)+1];strcpy(course,the_course);}~TeachingMaterial(){delete[]course;}constchar*theCourse()const{returncourse;}//返回相关课程的名称};intmain(){TeachingMateriala—book("c++语言程序设计",299,"张三","面向对象的程序设计");cout<<"教材名:"<<abook.theTitle()<<end1<<"页数:"<<abook.numOfPages()<<end1<<"作者:"<<abook.theWriter()<<end1//**********found**********<<"相关课程:"<<________;cout<<end1;return0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中声明的Matrix是一个用于表示矩阵的类。其成员函数transpose的功能是实现矩阵的转置运算。将矩阵A的行列互换,所得到的矩阵称为A的转置,记做AT。例如,若有3×3矩阵则A的转置为请编写成员函数transpose,以实现矩阵转置功能。要求:补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。//Matrix.h#include<iostream>#include<iomanip>usingnamespacestd;constintM=18;constintN=18;classMatrix{intarray[M][N];public:Matrix(){}intgetElement(inti,intj)const{returnarray[i][j];}voidsetElement(inti,intj,intvalue){array[i][j]=value;}voidtranspose();voidshow(constchar*s)const{cout<<endl<<s;for(inti=0;i<M;i++){cout<<endl;for(intj=0;j<N;j++)cout<<setw(4)<<array[i][j];}}};voidreadFromFile(constchar*,MatrixvoidwriteToFile(char*,constMatrix//main.cpp#include<fstream>#include"Matrix.h"voidreadFromFile(constchar*filename,Matrixif(!infile){cerr<<"无法读取输入数据文件!/n";return;}intd;for(inti=0;i<M;i++)for(intj=0;j<N;j++){infile>>d;m.setElement(i,j,d);}}voidMatrix::transpose(){//********333********//********666********}intmain(){Matrixm;readFromFile("",m);m.show("Beforetranspose:");m.transpose();m.show("Aftertranspose:");writeToFile("",m);return0;}
进入题库练习
问答题简单应用题 请编写函数fun(),其功能是将s所指字符串中除了下标为奇数、同时ASCII值也为奇数的字符之外,其余的所有字符都删除。字符串中剩余的字符所形成的一个新的字符串放在t所指的数组中。 例如:s所指字符串中的内容为ABCDEFG12345,其中字符A的ASCII码值虽为奇数,但元素所在的下标为偶数,因此必需删除;字符1的ASCII码值为奇数,所在数组中的下标也为奇数,不删除,最后t所指的数组中的内容应是135。 请勿修改主函数main和其他函数中的任何内容,仅在函数su的花括号中填写若干语句。 文件kt12_2.cpp的内容如下: #include #include #include #include voidfun(char*s,chart[]) { } voidmain() { chars[100],t[100]; cout<<"PleaseenterstringS:"<
进入题库练习
问答题使用VC6打开下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整,使得程序输出21到屏幕。完成以下功能:(1)增加静态私有变量m_Number,类型为int,请在注释//********1********后添加适当的语句。(2)增加静态变量m_Number并初始化为10,请在注释//********2********后添加适当的语句。(3)完成静态函数get的定义,请在注释//********3********后添加适当的语句。(4)完成对象obj对静态函数get的调用,使得输出21到屏幕上,请在注释//********4********后添加适当的语句。注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>classTestClass{//********1********intm_other;public:TestClass(inti){m_Other=i;}//********3********{returnm_Number+obj->m_Other;}};//********2********intmain(),{TestClassobj(11);//********4********coutendl;return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义类CPoint的带有两个参数的构造函数,两个变量为x、y都为int型,且缺省值为0。请在注释∥********1********后添加适当的语句。 (2)完成类CRectangle的构造函数,给pointl和point2进行赋值。请在注释∥********2********后添加适当的语句。 (3)完成类CRectangle的函数GetArea(),用来计算矩形面积。请在注释∥********3********后添加适当的语句。 (4)定义CRectangle类,拥有两个私有对象pointl和point2, 类型为Point, 请在注释∥********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include #include Class CPoint { public: ∥********1******** { x=i; y=1; } int GetX() { return x; } int GetY() { return y; } private: int X,Y; }; Class CRectangle { public: ∥********2******** { } int GetArea() { ∥********3******** int height=point1.GetY() 一point2.GetY(); return(width。height)? width*height:一width*height; } int GetGi rth() { int width=abs(pointl. GetX()一point2.GetX()); int height=abs(pointl. GetY()一point2.GetY()); return (2*(width+height)); } private: ∥********4******** CPoint point2; }; int main() { CRectangle rect(5,2,13,18); cout<
进入题库练习
问答题请编写一个函数int stringLen(char*ps),该函数能计算出字符串ps的长度,函数返回值就是字符串的长度(不包括字符串结束标识号'/0')。本题要求:用指针方式及循环来实现该函数。 注意;部分源程序已存在考生文件夹下的文件PROC6,cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数stringLen()的花括号中填写若干语句。 文件PROC6.cpp的内容如下: //PROC6.cpp #include<iostream> using namespace std; int stringLen(char *); int main() char str[100],*p; cout<<"Input your string please!/n"; cin>>str; p=str; cout<<"The lenth of your string is "<<stringLen(p)<<end1; return 0; int stringLen(char *ps) // * * * * *
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错误,请改正错误,使得程序正常运行。并使程序输出结果为:ABCDEFABCDEFABCDEF注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。#include<iostream.h>void main(){//********error********char s1[]="ABC"DEF";//********error********char s2[]="ABCDEF";//********error********char s3[]="ABC"+"DEF";cout<<s1<<endl;cout<<s2<<endl;cout<<s3<<endl;return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示人基本信息的类CHumanlnfo,但类CHumanlnfo的定义并不完整。请按要求完成下列操作,将类CHumanlnfo的定义补充完成: (1)定义私有数据成员bloodType用于表示血型,血型为char型的数据。请在注释“//********1********”之后添加适当的语句。 (2)完成构造函数的定义,要求具有缺省值,缺省值为身高175,体重70,血型A。请在注释“//********2********”之后添加适当的语句。 (3)完成类外CHumanInfo成员函数Setlnfo的定义。请在注释“//********3********”之后添加适当的语句。 (4)在主函数中调用成员函数SetInfo,把对象d2的三个私有数据成员分别设定为身高170,体重64,血型为B。请在注释“//********4********”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>class CHumanInfo{private: int height; int weight; //********1********public: //********2******** :height(ht),weight(wt),bloodType(bt){}; CHumanInfo(CHumanInfo &h1):height(h1.height), weight(h1.weight),bloodType(h1.bloodType){}; int GetHeight() { return height; } int GetWeight() { return weight; } int GetBloodType() { return bloodType; } void SetInfo(int ht,int wt,char bt); void Display(); }; //********3******** { height=ht; weight=wt; bloodType=bt; } void CHumanInfo::Display() { cout<<"HumanInfo:"; cout<<height<<"cm, "<<weight<<"Kg,BloodType"<<bloodType<<end1;}void main(){ CHumanInfo h1(169,61,'A'); CHumanInfo h2; CHumanInfo h3(h1); CHumanInfo h4(h2); //********4******** h1.Display(); h2.Display(); h3.Display(); h4.Display();}
进入题库练习
问答题简单应用题 请编写一个函数int CalcDigital(char *str),该函数可返回字符串str中数字字符(即''0''-''9''这10个数字)的个数,如字符串"olympic2008"中数字字符的个数为4。请用if条件判断语句与for循环语句来实现该函数。 注意:部分源程序已存在文件test9_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数find的花括号中填写若干语句。 文件test9_2.cpp的内容如下: #include #include int CalcDigital(char *str); void main() { char *str; str=new char[255]; cout>str; int num=CalcDigital(str); cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出: 10 TestClass1 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。 #include<iostream> class TestClass1 { public: TestClass1(){ }; //********error******** private: virtual~TestClass1() { using namespace std;cout<<''TestClass1''<<endl; };}; iass TestClass2:public TestClass1{public: //********error******** explicit TestClass2(int i) { m__i=i; }; TestClass2& operator ()(int i) { this->m__i=i; } void print() {//********error******** cout<<m__i<<endl; }private: int m__i;};void fun(TestClass2 C1){ C1.print();}int main(){ fun(10); return 0;}
进入题库练习