计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题请使用VC6或使用【答题】菜单打开考生文件夹prog2下的工程prog2。此工程中包含一个程序文件main.cpp,其中有“部门”类Department和“职工”类Staff的定义,还有主函数main的定义。在主函数中定义了两个“职工”对象,他们属于同一部门。程序展示,当该部门改换办公室后,这两个人的办公室也同时得到改变。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为:改换办公室前:职工号:0789姓名:张三部门:人事处办公室:521职工号:0513姓名:李四部门:人事处办公室:521改换办公室后:职工号:0789姓名:张三部门:人事处办公室:311职工号:0513姓名:李四部门:人事处办公室:311注意:只在横线处填写适当的代码,不要改动程序中的其他内容。#include<iostream>usingnamespacestd;classDepartment{//“部门”类public:Department(constchar*name,constchar*office){strcpy(this->name,name);//**********found**********}constchar*getName()const{returnname;)//返回部门名称//**********found**********constchar*getOffice()const{________}//返回办公室房号voidchangeOfficeTo(constchar*office){//改换为指定房号的另一个办公室strcpy(this->office,office);}private:charname[20];//部门名称charoffice[20];//部门所在办公室房号};classStaff{//“职工”类public://**********found**********Staff(constchar*my_id,constchar*my_name,Department&my_dept):________{strcpy(this->staff_id,my_id);strcpy(this->name,my_name);}constchar*getID()const{returnstaffid;}constchar*getName()const{returnname;}DepartmentgetDepartment()const{returndept;}private:charstaffid[10];//职工号charname[20];//姓名Department&dept;//所在部门};voidshowStaff(Staff&staff){cout<<"职工号:"<<staff.getID()<<"";cout<<"姓名:"<<staff.getName()<<"";cout<<"部门:"<<staff.getDepartment().getName()<<"";cout<<"办公室:"<<staff.getDepartment().getOffice()<<end1;}intmain(){Departmentdept("人事处","521");StaffZhang("0789","张三",dept),Li("0513","李四",dept);cout<<"改换办公室前:"<<end1;showStaff(Zhang);showStaff(Li);//人事处办公室由521搬到311//**********found****卡*****cout<<"改换办公室后:"<<end1;showStaff(Zhang);showStaff(Li);return0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程prog3,其中声明了ValArray类,该类在内部维护一个动态分配的int型数组v。ValArray类的成员函数cycle用于对数组元素进行向左循环移动。调用一次cycle后,数组的第二个元素至最后一个元素都将向左移动一个位置,而最左端的元素将循环移动到最右端位置上。例如,若ValArray表示的数组为{1,2,3,4,5},则第一次调用cycle后,数组变为{2,3,4,5,1},第二次调用cycle后,数组变为{3,4,5,1,2},依次类推。请编写成员函数cycle。在main函数中给出了一组测试数据,此情况下程序的输出应该是: v={1,2,3,4,5} v={2,3,4,5,1} v={3,4,5,1,2} v={4,5,1,2,3} v={5,1,2,3,4} 要求: 补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //ValArray.h #include <iostream> using namespace std; class ValArray { int* v; int size; public: ValArray const int* p, int n): size (n) { v = new int[size]; for (int i = 0; i<size; i++) v[i] = p[i]; } ~ValArray() { delete [] v; } void cycle (); void print(ostream for (int i = 0; i <size-1; i++) out << v[i] << ","; out << v[size-1] << '}'; } }; void writeToFile (const char * ); //main. cpp #include "ValArray. h" void ValArray::cycle () { //将数组v中的size个整数依次移动到它的前一个单元,其中第一个整数移到原来最后元素所在单元。 //******** 333******** //******** 666******** } int main ( ) { const int a[] = {1, 2, 3, 4, 5 }; ValArray v(a, 5); for (int i = 0; i < 5; i++) { cout << "v = "; v.print (cout); cout << endl; v.cycle(); } writeToFile (""); return 0; }
进入题库练习
问答题使用VC6打开考生牛文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。函数num(char*str)实现返回字符串中非数字的个数。 例如:abc123abc45 返回输出:6 将函数num()%b充完整。 注意:请勿改动主函数。 #include int num(char*str) { } int main() { char str[1024]; cout<<"please input a string: "<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义类CPoint的带有两个参数的构造函数,两个变量为x、y都为int型,且缺省值为0。请在注释//********1********后添加适当的语句。 (2)完成类CRectangle的构造函数,给pointl和point2进行赋值。请在注释//********2********后添加适当的语句。 (3)完成类CRectangle的函数GetArea0,用来计算矩形面积。请在注释//********3********后添加适当的语句。 (4)定义CRectangle类,拥有两个私有对象pointl和point2,类型为Point,请在注释//********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>#include<cmath>Class CPoint{public: //********1******** { x=i; y=j; } int GetX() { return x; } int GetY() { return y; }private: int x,y;};class CRectangle{public: //********2******** { } int GetArea() { //********3******** int height=pointl.GetY()-point2.GetY(); return(width*height)?width*height:一width*height; } int GetGirth() { int width=abs(point1.GetX()-point2.GetX()); int height=abs(point1.GetY()-point2.GetY()); return(2*(width+height)); }private: //********4******** CPoint point2;};int main(){ CRectangle rect(5,2,13,18); cout<<rect.GetArea()<<endl; cout<<rect.GetGirth()<<endl; return 0;}
进入题库练习
问答题使用VC6打开下的源程序文件modi1.cpp,使它能得出正确的结果。本程序要求屏幕输出:n=99注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。#include<iostream.h>//********error********classTestClass(){public://********error********void~TestClass(){};TestClass(intn){;};//********error********}voidmain(){TestClasstest(99);return;}
进入题库练习
问答题使用VC6打开下的源程序文件modi1.cpp,该程序运行时有错误,请改正错误,使得程序通过运行。程序输出:5a1注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream>template<classT>//********error********tmin(tx,ty){return(x>y)?y:x;}voidmain(){intn=5;//********error********charc="a";intd=1;//********error********coutmin(n,n)endl;coutmin(c,c)endl;coutmin(d,d)endl;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个源程序文件proj2.cpp。其中定义了模板函数insert(T dataset[],int //请在该部分插入insert函数模板的实现 template <typename T> void insert(T setdata[], int i < size; i++) //**********found********** if (______) { //TODO: 添加代码,判断查找元素的插入位置 for (int j = i; j < size; j++) //**********found********** ______; //TODO: 添加一条语句,将插入位置后的所有元素往后移动一个位置 //提示:移动元素应从最后一个元素开始移动 setdata[i] = item; //插入该元素 size ++; return; } //********** found********** ______; //TODO: 添加一条语句,将元素加到最后一个位置上 size ++; return; } int main () { int idata[10] = {22, 35, 56, 128 },iitem, isize = 4, dsize = 4, i; double ddata[10] = {25.1, 33.5, 48.9, 75.3], ditem; cout << "Please input one integer number for inserting:"; cin >> iitem; insert(idata, isize, iitem); for (i = 0; i< isize; i++) cout << idata[i] << "; cout << endl; cout << "Please input one doublenumber for inserting:"; cin >> ditem; insert(ddata, dsize, ditem); for (i = 0; i < dsize; i++) cout << ddata[i] << "; cout << endl; return 0; }
进入题库练习
问答题使用VC6打开下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为:TestClass1TestClass2注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>#include<assert.h>StructTeStClass0{//********error********virtualvoidfun();};classTestClass1:publicTestClass0{voidfun(){cout"TestClass1"endl;}};classTestClass2:publicTestClass0{voidfun(){cout"TestClass2"endl;}};voidmain(){TestClass0*p;TestClass1obj1;TestClass2obj2;//********error********p=*obj1;p->fun();//********error********p=*obj2;p->fun();return;}
进入题库练习
问答题编写一个函数int charnum(char fn[10]),该函数以只读方式打开文件fn,通过统计,返回文件中字符的个数,请使用while循环实现计数功能。 注意:部分源程序已存在文件test7_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数charnum的花括号中填写若干语句。 文件test7_2.cpp的内容如下: #include<iostream.h> #include<fstream.h> #include<stdlib.h> int charnum(char fn[10]); void main() int num; num=charnum("abc.txt"); cout<<"num="<<num<<endl; int charnum(char fn[10])
进入题库练习
问答题请使用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_room_no),length(the_length),width(the width) int theRoomNo()constreturn room_no; //返回房间号 double theLength()const returnlength;) //返回房间长度 double theWidth()const returnwidth; //返回房间宽度 //**********found********** double theArea()const______ //返回房间面积(矩形面积) ; class Office:public Room //“办公室”类char*depart; //所属部门 public: Office (int the_room_no.double the_length,double the_width,constchar*the_depart) //**********found********** :______ depart=new char[strlen(the depart)+1]; //**********found********** strcpy(______); ~Office()delete[]depart; const char*theDepartment()constreturn depart;)//返回所属部门 ; int main() //**********found********** Office______; cout<<"办公室房间号:"<<an office.theRoomNo()<<endl <<"办公室长度:"<<an office.the-Length()<<endl <<"办公室宽度:"<<an office.the-Width()<<endl <<"办公室面积:"<<an_office.theArea()<<endl <<"办公室所属部门:"<<an office.theDepartment()<<endl; return 0;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 5 1 注意:错误的语句在//********error********的下面,修改该语句即可。#include<iostream.h>//********error********enum{ Sun, Mon, Tue, Wed, Thu, Fri, Sat, //********error********}MyEnum;struct struct{ **********error******** int Fri, int Sun;};Void main(){ int i=Mon; MyEnum t=Fri; struct str1; str1.Fri=Mon; cout<<i<<endl; cout<<t<<endl; cout<<str1.Fri<<endl;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)重载运算符int, 请在注释//********1********后添加适当的语句。 (2)重载运算符“<<”,请在注释//********2********后添加适当的语句。 (3)在主函数main()中定义变量i,并调用对象obj的int运算符,给变量赋初值为10,请在注释//********3********后添加适当的语句。 (4)调用obi的“<<”运算符输出: HelloTest 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。3include<iostream>using namespace std;class TestClass{public://********1******** { cout<<"int"<<end1; return 10; } //********2******** { cout<<str<<end1; }};int main(){ TestClass obj; //********3******** //********4******** return 0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中声明的CDeepCopy是一个用于表示动态数组的类。请编写其中的复制构造函数。 要求: 补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //CDeepCopy.h #include <iostream> #include <string> using namespace std; class CDeepCopy { public: int n; //动态数组的元素个数 int * p; //动态数组首地址 CDeepCopy (int); ~CDeepCopy (); CDeepCopy(const CDeepCopy //复制构造函数 }; void writeToFile (char * ); //main. cpp #include "CDeepCopy. h" CDeepCopy:: ~CDeepCopy () { delete [] p;} CDeepCopy::CDeepCopy (int k) { n = k; p=new int[n];} CDeepCopy:: CDeepCopy ( const CDeepCopy a.p[0] =1; d.p[0] =666; //对象a,d数组元素的赋值 { CDeepCopy b (a); a.p[0] =88; cout <<b.p[0]; //显示内层局部对象的数组元素 } cout <<d.p[0]; //显示d数组元素a.p[0]的值 cout <<" d fade away; /n"; cout <<a. p[O]; //显示a数组元素a.p[0]的值 writeToFile (""); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: False 注意:请勿更改参数名。只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 //proj1.cpp #include <iostream> using namespace std; class MyClass { public: // ERROR ******** found******** void MyClass (int x):flag(x) { } void Judge (); private: int flag; }; // ERROR ******** found******** void Judge () { switch (flag) { case 0: cout <<"False" << endl; // ERROR******** found******** exit; default: cout << "True" << endl; break; } } int main ( ) { MyClass obj (0); obj. Judge (); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成类MyArrayClass的构造函数,申请数组的大小,请在注释//********1********后添加适当的语句。 (2)完成类MyArrayClass的析构函数,释放数组,请在注释//********2********后添加适当的语句。 (3)完成重载运算符“[]”,用来获得指定下标的数据,请在注释//********3********后添加适当的语句。 (4)完成函数SetElement(),用来设置指定下标的数据。如果数据没有超出范围,则设置数据,并返回1,否则返回0,请在注释//********4********后添加适当的语句。 注意:除在指定的位置添加语句外,并不要更改程序中的其他语句。#include<i0stream.h>template<class T>class MyArrayClass{private: T* data; int length;public: MyArrayClass(int fen) { length=len; //********1******** ) ~MyArrayClass() ( //********2******** } T&operator[](int i) { //********3******** } bool SetElement(int i,T t) { //********4******** if() { data[i]=t; return true; } return false; } }; int main() { MyArrayclass<int>obj(5); obj[3]=1; cout<<obj.SetElement(5,2)<<endl; cout<<obj.SetElement(4,2)<<endl; return 0;}
进入题库练习
问答题使用VC++6.0打开 下的源程序文件2.cpp。完成fun()函数,其功能是:求出M行N列二维数组每行元素中的最小值,并计算它们的和。和通过形参传回主函数并输出。 注意:不能修改程序的其他部分,只能修改fun()函数。 试题程序: #include <iostream.h> #define M 2 #define N 4 void fun(int a[M][N],int *sum) { } void main() { int x[M][N]={7,6,5,2,4,2,8,3}; int s; fun(x, cout<<s<<endl; return; }
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp,其中定义了用于表示人基本信息的类CHumanInfo,但类CHumanInfo的定义并不完整。请按要求完成下列操作,将类CHumanInfo的定义补充完成: (1)定义私有数据成员bloodType用于表示血型,血型为char型的数据。请在注释“//********1********”之后添加适当的语句。 (2)完成构造函数的定义,要求具有缺省值,缺省值为身高175,体重70,血型A。请在注释“//********2********”之后添加适当的语句。 (3)完成类外CHumanInfo成员函数SetInfo的定义。请在注释“//********3********之后添加适当的语句。 (4)在主函数中调用成员函数SetInfo,把对象d2的三个私有数据成员分别设定为身高170,体重64,血型为B。请在注释“//********2********”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include<iostream.h> class CHumanInfo { private: int height; int weight; //********1******** public: //********2******** : height(ht),weight(wt), bloodType(bt) {}; CHumanInfo(CHumanInfo 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 endl; } void main() { CHumanInfo h1(169, 61, "A"); CHumanInfo h2; CHumanInfo h3(h1); CHumanInfo h4(h2); //********4******** h1.Display(); h2.Display(); h3.Display(); h4.Display(); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错误,请改正错误,使得程序输出: Hello test 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream>//********error********template<T>Void fun(T t){ std::cout<<"test"<<std::endl;}//********error********template<bool>Void fun(bool t){ std::cout<<(t?"Hello":"Hi")<<std::endl;}int main(){ //********error******** bool flag=TRUE; fun(flag); fun((int)flag); return 0;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,该程序运行时有误,请改正其中的错误,使程序正常运行,并使程序在界面上输出为: 平均值为:29 最大值为:112 最小值为:-11 注意:错误的语句在//******error******的下面。修改该语句即可。 #include<iostream> using namespace std; int main() { int i,Ave,Min,Max; int data[8]={0,112,43,78,-11,-6,7,9}; Ave=0; for(i=0; i<8; i++) //******error****** Ave=data[i]; Ave/=8; cout "平均值为:" Ave endl; Max=Min=data[0]; for(i=0;i<8;i++) { //******error****** if(data[i]<Max) Max=data[i]; //******error****** if(data[i]>Min) Min=data[i]; } cout "最大值为:" Max endl; cout "最小值为:" Min endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。通过继承完成输入到屏幕指定的信息: TestClassA TestClassB TestClassC 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)完成类B虚继承于A,请在注释∥********1********后添加适当的语句。 (2)完成类C虚继承于A,请在注释∥********2********后添加适当的语句。 (3)完成类D继承于B,C,请在注释∥********3********后添加适当的语句。 (4)函数fun通过调用基类的fun,完成所输出的内容,请在注释∥********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include Class TeStClassA { public: void fun(){ cout<<“TestClassA”<
进入题库练习