计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,其中有矩形类Rectangle、函数show和主函数main的定义。程序中位于每个“//ERROR****found****”下一行的语句有错误,请力11以改正。改正后程序的输出结果应该是:Upperleft=(1,8),downright:(5,2),areal=24.注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>#include<cmath>usingnamespacestd;classRectangle{doublex1ty1;//左上角坐标doublex2,y2;//右下角坐标public://ERROR**********found**********Rectangle(doublex1,y1;doublex2,y2){this->x1=x1;this->y1=y1;thiS->x2=x2;this->y2=y2;}doublegetXl()const{returnx1;}doublegetYl()const{returny1;}doublegetX2()const{returnx2;}doublegetY2()const{returny2;}doublegetHeight()const{returnfabs(y1—y2);}doublegetWidth()constfreturnfabs(x1—x2);}doublearea()const{returngetHeight()*getWidth();}};//ERROR**********found**********voidshow(Rectangler)const{cout<<"Upperleft=(";//ERROR**********found**********cout<<r.x1<<”,”<<r.y1<<”),downright=("<<r.x2<<","<<r.y2;cout<<"),area="<<r.area()<<"."<<end1;}intmain(){Rectanglerl(1,8,5,2);show(r1);return0;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成构造函数,设置数组元素的个数为0,请在注释//********1********之后添加语句。 (2)完成函数AddMember(int n),如果参数n包含在类的数据成员数组中,则返回0,否则把数据写入数组,然后返回1,请在注释//********2********之后添加语句。 (3)完成函数DelMember(int n),如果变量在数据中,则删除该变量,并且返回1,如果不存在则返回0,请在注释//********3********之后添加语句。 (4)完成成员函数isInclude(int n)的定义,该函数检查参数n是否在类的数据成员数组elems中,如果在返回1,否则返回0。请在注释//********4********之后添加语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include<iostream.h> #define MAX_LENGTH 500 class CArray { public: CArray ( ) { //********1******** } int AddMember(int n) { for (int i=0; i<length; i++) { //********2******** if(Array[i]=n) return 0; } Array [length++]=n; return 1; } int DelMember (int n) { int i; for(i=0;i<length;i++) { if( Array[i]==n) { break; } } //********3******** if() { for(; i<length-1; i++) { Array[i]=Array [i+1]; } length--; return 1; } return 0; } int isInclude(int n) { for (int i=0; i<length;i++) { //********4******** if() { return 1; } } return 0; } private : int Array [MAX_LENGTH]; int length;用来记录数组的个数 }; int main() { CArray obj; obj.AddMember (1); obj.AddMember (3); obj.AddMember (8); obj.AddMember (23); cout obj.isInclude (8) endl; cout obj.isInclude (11) endl; obj. DelMember (3); obj. DelMember (8); cout obj, is Include (2) endl; cout obj .isInclude (1) endl; return 0; }
进入题库练习
问答题使用VC6打开考 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)声明类objA1,请在注释//********1********后添加适当的语句。 (2)为类objA0增加友元函数func(),请在注释//********2********后添加适当的语句。 (3)为类objA1增加友元函数func(),请在注释//********3********后添加适当的语句。 (4)函数func()返回objA1对象中的变量和objA0的静态变量的乘积,请在注释//********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include<iostream.h> //********1******** class objA0 { private: static int m_A0; //********2******** }; int objA0::m_A0=10; class objA1 { private: int m_A1; //********3******** public: objA1(int i) { m_A1=i; } }; int func (objA1 cout func(obj0) endl; return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj2下的工程proj2,该工程中包含一个程序文件main.cpp,其中有类CPolygon(“多边形”)、CRectangle(“矩形”)、CTriangle(“三角形”)的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。该程序的正确输出结果应为: 20 10 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“// ****found****”。 #include <iostream> using namespace std; class CPolygon { public: // **********found********** ______//纯虚函数area声明 void printarea (void) // **********found********** {cout <<______<< endl;} }; class CRectangle: public CPolygon { int width; //长方形宽 int height; //长方形高 public: CRectangle (int w, int h): width (w), height (h) {} int area (void) {return (width * height);} }; class CTriangle : public CPolygon { int length; //三角形一边长 int height; //该边上的高 public: CTriangle (int 1, int h): length (1), height (h) {} // **********found********** int area (void) {return (______)/2;} }; int main() { CRectangle rect (4,5); CTriangle trgl (4,5); // **********found********** ______*ppoly1, *ppoly2; ppoly1 = ppoly2 = ppoly1 -> printarea(); ppoly2 -> printarea(); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。程序通过继承关系,实现对姓名的控制。 类TestClass1实现对名字访问的接口,TestClass2实现对名字的设置和输出。 程序输出为: TestClass2Name May 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)在类TestClassl中定义接口函数GetName,为纯虚函数。请在注释∥********1********后添加适当的语句。 (2)函数GetName20实现获得名字的缓存,但是只获得读允许操作这个缓存,请在注释∥********2********后添加适当的语句。 (3)实现TestClass2的构造函数,请在注释∥********3********后添加适当的语句。 (4)完成TestClass2的构造函数,实现对名字的处理。请在注释∥********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include class TestClass1 { public: ∥********1******** }; class TestClass2:public TestClass1 { public: void GetName() { CoutGetName(); cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义私有常量PI,请在注释//********1********后添加适当的语句。 (2)完成类的私有常量PI的赋值,以及完成对半径radius的赋值。请在注释//********2********后添加适当的语句。 (3)完成计算圆面积的函数GetArea()。请在注释//********3********后添加适当的语句。 (4)完成计算圆周长的函数GetGirth()。请在注释//********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>#define CONST_PI 3.141592class CCircle{private: double radius; //********1********public: //********2******** CCircle(int radius) {this->radius=radius; } double GetArea() { //********3******** ) double GetGirth() { //********4********} void SetRadius(int m) { radius=m; }};int main(){ CCircle circle(5); cout<<circle.GetArea()<<end1; cout<<circle.GetGirth()<<end1; circle.SetRadius(10); cout<<circle.GetArea()<<end1; cout<<circle.GetGirth()<<end1; return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (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 Time year:08 month:04。 (4)完成对month的增加函数AddMonth(int m),请在注释//********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>class CMyTime{private: //********1********public: CMyTime(int year,int month) { //********2******** } void display() { char yearChar[3]; char monthChar[3]; yearChar[0]=(m_year%100)/10+'0'; yearChar[1]=(m_year%10)+'0'; monthChar[0] =(m_month%100)/10+'0'; monthChar[1] =(m_month%10)+'0'; //********3******** cout<<"Current Time"<<" year: "<<yearChar<<" month:"<<monthChar<<endl; } Void AddMonth(int m) { m month=m month一1+mj //********4******** m month=m month%12+1; } Void AddYeam(int n) { m_year=m_year+n; }};int main(){ CMyTime myTime(2006,11); myTime.AddMonth(5); myTime.display(); myTime.AddYear(1); myTime.display(); return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数convert(cha*des,char*str)实现的功能是: (1)如果字符串最后面有空格,则全部删除; (2)转换后的数据放到des,并且指针作为返回值返回。 注意:不能修改程序的其他部分,只能补充convert()函数。 #include #inciude #define NAXLEN 1024 char* convert.(char*des,char* sir) { } void main() { char dest;[NAXI,EN]; char*string=“abc def ”; cout; << string <<“<一一” << endl; cout<
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义复数类CComplex的私有成员变量real和imaginary,分别用来表示复数的实部和虚部,都是double类型的变量。请在注释//********1********后添加适当的语句。 (2)添加复数类CComplex的带一个参数的构造函数,分别将real和imaginary赋值为参数r和0。请在注释//********2********后添加适当的语句。 (3)完成对运算符“+”的重载,分别对复数的实部和虚部相加。请在注释//********3********后添加适当的语句。 (4)完成复数的友元函数Equal(CComplex } CComplex(double r) { //********2******** } CComplex operator+(CComplex temp.imaginary=imaginary+c1.imaginary; return temp; } void Set(int re,int imag) { real=re; imaginary=imag; } friend bool Equal(CComplex }; bool Equal(CComplex CComplex complex2; cout Equal(complex1,comp lex2) endl; complex2.Set(5,0); cout Equal(complex1,comp lex2) endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数fun(int*arr,int n)的功能是将指定的有序数组压缩成各元素互不相同的有序数组,即相同数只保留一个,多余的被删除。并返回互不相同的元素的个数。 注意:不能修改程序的其他部分,只能修改fun()函数。#include<iostream>int fun(int*a,int n){}void main(){ int A[]={6,6,5,4,4,3,3,2,1}; int j =fun(A,sizeof(A)/sizeof(int)); for(int i=0;i<j;i++) { std::cout<<A[i]<<' '; } Std::cout<<std::end1; return;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1,此工程包含有一个源程序文件proj1.cpp。其中位于每个注释“// ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: (4,4) 注意:只修改注释“// ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 // proj1.cpp #include <iostream> using namespace std; class Point{ public: // ERROR *******found******* Point(double x, double y) _x(x), _y(y) {} double GetX() const {return _x;} double GetY() const {return _y;} // ERROR *******found******* void Move (double xOff, double yOff) const {_x + = xOff; _y + = yOff;} protected: double _x, _y; }; int main() { Point pt(1.5, 2.5); pt.Move(2.5, 1.5); // ERROR *******found******** 以下语句输出pt成员_x和_y的值 cout << "(" << pt._x << "," << pt._y << ")"<< endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的工程test10_3,此工程包含一个源程序文件test10_3.cpp,其中定义了用于表示雇员信息的CEmployee类与表示公司信息的Company类,但这两个类的定义并不完整。请按要求完成下列操作。 (1)定义Cemployee类的私有数据成员name(大小为50的字符数组)和pay(double型数据),分别用于记录雇员姓名和月薪。请在注释“//**1**”之后添加适当的语句。 (2)完成Company类默认构造函数的定义,该构造函数将n值赋值给私有成员nam,并完成指针emp所指的n个 Cemployee对象空间的申请,请在注释“//**2**”之后添加适当的语句。 (3)完成Company类成员函数void Company::add(int code,charname[50],doublepay)的定义,该函数将某一雇员的编号 code、姓名name及月薪pay输入到公司信息中。请在注释“//**3**”之后添加适当的语句。 (4)完成Company类成员函数void Company::print()的定义,使其以“_is paid_RMB for oue month”的格式输出公司内所有员工的月薪信息。请在注释“//**4**”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件test10_3.cpp清单如下: #include<iostream.h> #include<string.h> class CEmployee public: void putname(char n[50])strcpy(name,n);) void getname(char n[501)strcpy(n,name);) void putpay(double d)pay=d;) double getpay()return pay;) private: //**1** ; class Company private: CEmployee *emp; int num; public: Company(int n); void add(int code,Char name[50],double pay); void print(); Company::Company(int n) //**2** void Company::add(int code,Char name[50],double pay) //**3** void Company::print() //**4** for(int i=0;i<num;i++) (emp+i)->getname(C); money=(emp+i)->getpay(); cout<<C<<" is paid "<<money<<" RMB for one month"<<endl; void main() Company com(2); com.add(0,"Jack",200); com.add(1,"Lee",300); com.print();
进入题库练习
问答题简单应用 请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程含有一个源程序文件proj2.cpp, 其中定义了Stack类和ArrayStack类。请在程序中"//****found****"下的横线处填写适当的代码,然后删除横线。此程序的输出结果应为: c, b, a 注意:只需在指定位置编写适当代码,不要改动程序中的其他内容, 也不能删除或移动"//****found****"。 #include using namespace std; class Stack { //抽象栈类的定义 public: virtual void push(char c) = 0; //元素进栈 virtual char pop() = 0; //元素出栈 }; class ArrayStack : public Stack { //派生栈类的定义 char *p; // 指向存放栈元素的字符数组 int maxSize; // 栈的最大容量 int top; // 栈顶位置 public: ArrayStack(int s) //s表示栈的最大容量 { top = -1; //top值为-1表示栈空 maxSize = s; //********found******** p = new _____________; //为字符数组动态分配maxSize个单元的栈空间 } ~ArrayStack() { //********found******** delete ______; // 释放字符数组p的存储空间 } void push(char c) { if (top==maxSize-1) { cerr<<"Overflow!/n"; return; } //********found******** p[++top]=__________; // 将字符c压入栈内 } char pop() { if (top==-1) { cerr<<"Underflow!/n"; return '/0'; } //********found******** return_____________; // 弹出并返回栈顶元素 } }; int main() { ArrayStack as(10); as.push('a'); as.push('b'); as.push('c'); cout < cout< cout< return 0; }
进入题库练习
问答题使用VC++6.0打开 下的源程序文件1.cpp,该程序运行时有错,请改正程序中的错误,使程序输出的结果为 10 6 30 2 2 注意:错误的语句在//******error******的下面,修改该语句即可。 试题程序: #include<iostream.h> class TC { private: int number; int Add(int i) { return number+=i; } int Sub(int i) { return number-=i; } int Mul(int i) { return number*=i; } int Div(int i) { if(i! =0) { return number/=i; } else return number; } //******error****** typedef int(FUNC)(int); //******error****** FUNC func[]; public: TC() { func[0]=TC::Add; func[1]=TC::Sub; func[2]=TC::Mul; func[3]=TC::Div; number=0; } int CallFunction(int i,int j) { //******error****** return(func[i])(j); } }; void main() { TC myobj; cout<<myobj.CallFunction(0,10)<<endl; cout<<myobj.CallFunction(1,4)<<endl; cout<<myobj.CallFunction(2,5)<<endl; cout<<myobj.CallFunction(3,15)<<endl; cout<<myobj.CallFunction(3,0)<<endl; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并且使程序输出的结果为: a=7,b=0 a=8,b=10 注意:错误的语句在//*****error******的下面,修改该语句即可。#include<iostream.h>class CObj{public: //*****error****** friend void func(CObj&,int,int); void display() {//*****error******cout<<"a:"<<a<",b="<<<<b<<end1; }private: int a,b;};void func(CObj&obj,int t){ obj.a=t; obj.b=0;}void func(CObj&obj,int t,int j){ obj.a=t; obj.b=j;)void main(){ //*****error****** CObj obj 1 func(obj 1,7); obj 1.display(); func(obj 1,8,10); obj 1.display(); }
进入题库练习
问答题改错题 使用VC6打开考生文件夹下的工程test13_1,此工程包含一个源程序文件test13_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果如下: n=2 n=5 n=7 源程序文件test13_1清单如下: #include class Sample { int n; public: /***************** found *******************/ Sample() Sample(int i){n=i;} /***************** found *******************/ void add(Sample s1,Sample s2) /***************** found *******************/ { this.n=s1->n+s2.n; } void disp(){cout<<"n="<
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程包含有一个源程序文件proj2.cpp,其中定义了Stack类和ArrayStack类。 Stack是一个用于表示数据结构“栈”的类,栈中的元素是字符型数据。Stack为抽象类,它只定义了栈的用户接口,如下所示: 公有成员函数 功能 push 入栈:在栈顶位置添加一个元素 pop 退栈:取出并返回栈顶元素 ArrayStack是Stack的派生类,它实现了Stack定义的接口。ArrayStack内部使用动态分配的字符数组作为栈元素的存储空间。数据成员maxSize表示的是栈的最大容量,top用于记录栈顶的位置。成员函数push和poP分别实现具体的入栈和退栈操作。 请在程序中的横线处填写适当的代码,然后删除横线,以实现上述功能。此程序的正确输出结果应为: a,b,c c,b,a 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。//proj 2.cpp#include<iostream>using namespace std;class Stack{public: virtual void push(char c)=0; virtual char pop()=0;};class ArrayStack:public Stack{ char*P; int maxSize; int top;public: ArrayStack(int s) { top=0; maxSize=s;//*********found**********p=_____; } 一ArrayStack() {//*********found**********_________;}void push(char c){ if(top=maxSize){ cerr<<”Overflow!\n”; return; }//**********found**********_______; top++; } char pop() { if(top==0){ cerr<<”Underflow! \n”; return’\0’; } top--;//******** found********_________;}};void f(Stack&sRef){char ch[]={’a’,’b’,’C’);cout <<ch[0] <<”, ” <<ch[1] <<”,”<<ch[2]<<endl;sRef.push(ch[0]);sRef.push(ch[1]);sRef.push(ch[2]); cout<<sRef.pop()<<”,”; cout<<sRef.pop()<<”,”; cout<<sRef.pop()<<endl;}int main(){ ArrayStack as(10); f(as); return 0;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: number1=a number2=a number1=a number2=b 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> class CMyClass { public: //******error****** friend void SetValue(CMyClass obj,char c) { obj.number1=c; obj.number2=c; } //******error****** void SetValue(CMyClass obj, char c1,char c2 ) { obj.number1=c1; obj.number2=c2; } void display() { cout "number1=" number1 endl; cout "number2=" number2 endl; } private: char number1,number2; }; void main() { CMyClass t; SetValue(t,"a"); t.display(); //******error****** t.SetValue( t.display(); }
进入题库练习
问答题使用VC6打开考生文件夹下的工程test2_3。此工程包含一个test2_3.cpp,其中定义了类Stud,但类的定义并不完整。请按要求完成—下列操作,将程序补充完整。 (1)定义类的公有数据成员no,name[10],其中no是int型的数据,name[10]是字符型一维数组。请在注释“//**1**”之后添加适当的语句。 (2)完成函数set的定义,分别将参数n,na的值赋给数据成员no,name。注意:请使用this指针完成对no的赋值,使用字符串函数实现对name和cname的赋值。请在注释“//**2**”之后添加适当的语句。 (3)完成类的成员函数disp的定义,使其按no,deg,name和cname的顺序输出类的数据成员的值,中间使用跳格符分隔,请在注释“//**3**”之后添加适当的语句。 输出结果如下: 1 李华 95 990701 2 王东 83 990702 注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。 源程序文件test2_3.cpp清单如下: #include<iostream.h> #include<string.h> class Stud public: // ** 1 ** int deg; char cname[10]; Stud() void set(int n,char na[],int d,char cn[]) // ** 2 ** deg=d; strcpy(cname,cn); void disp() // ** 3 ** ; void main() Stud obj[2]; obj[0].set(1,"李华",95,"990701"); obj[1].set(2,"王东",83,"990702"); obj[0].disp(); obj[1].disp();
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。补充函数convert(long s,long*str),使之从低位开始取出长整型变量S中奇数位上的数,依次存放在数str中。 例如,当S中的数为:7654321时,str中的数为:7531。 注意:请勿改动主函数。 #include void convert(long s,long*str) { } void main() { long s,res; cout>s; convert(S,&res); cout<<“The result iS:”<
进入题库练习