计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开 下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: 30 130 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> int a=10; class CObj { public: CObj() { a=b=0; } void display() { //******error****** cout a b<endl; } void func(int a) { //******error****** a+=a; } void func2() { //******error****** a+=a; } private: int a,b; }; void main() { CObj obj; obj.func(3); obj.display (); obj.func2 (); obj.display (); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,要求编写一个CMyShape类,含有求面积求周长等纯虚函数。然后编写一个CMyRectangle类和CMyCirele类继承CMyShape,并实现求面积、求周长的两个函数。在mainC函数中测试得到下面的结果: 在CMyShape类构函数造内 在CMyCircle类构造函数内 在CMyShape类构造函数内 在CMyRectangle类构造函数内 myCircle:Area=314.159 Girth=62.8319 myRectangle:Area=900 Ginh=120 具体要求如下: (1)定义求面积纯虚函数,请在注释∥********1********之处添加适当的语句。 (2)定义求周长纯虚函数,请在注释∥********2********之处添加适当的语句。 (3)请在注释∥********3********和∥********4*******之处添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include #include #define PI 3.1415926 class CMyPoint { public: int x,y; CMyPoint(int tx,int ty): X(tx),y(ty){) }; class CMyShape { public: CMyShape(){coutGetArea() GetGirth()GetArea() GetGirth()<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。函数num(char*str)实现返回字符串中非数字的个数。 例如:abcl23abc45 返回输出:6 将函数num()补充完整。 注意:请勿改动主函数。 #include int num(char*str) { } int main() { char str[1024]; cout<<“please input a string:”<
进入题库练习
问答题用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按照要求完成下列操作,将类的定义补充完整。在屏幕和程序modi3.txt文件中输出以下结果: Hello Test 出现异常情况 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整: (1)以追加的方式打开文件modi3.txt,请在注释//********1********后添加适当的语句。 (2)定义一个类对象s,请在注释//********2********后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>#include<fstream>using namespace std;void WriteFile(char*x){ ofstream out1; //********1******** out1.open("modi3.txt", ); out1<<x<< ' '; outl.close(); } Void ClearFile() { ofstream out1; out1.open("modi3.txt"); out1.close(); } Class TestClass { public: TestClass() { cout<<"Hello"<<endl; WriteFile("Hello"); } ~TestClass() { cout<<"Test"<<endl; WriteFile("Test"); }};Void main(){ ClearFile(); try { //********2******** throw 1; } catch(int) { cout<<"出现异常情况"<<endl; WriteFile("出现异常情况"}; }}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 prog1下的工程prog1,该工程中包含程序文件main.cpp,其中有Salary(“工资”)类和主函数main的定义。程序中位于每个“// ERROR ****found****”之后的一行语句行有错误,请加以改正。改正后程序的输出结果应为: 应发合计:3500 应扣合计:67.5 实发工资:3432.5 注意:只修改每个“// ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> using namespace std; class Salary{ public: Salary(const char * id, double the_base, double the_bonus, double the_tax) // ERROR *******found******* : the_base (base), the_bonus (bonus), the_tax (tax) { staff_id = new char[strlen (id) +1]; strcpy (staff_id, id); } // ERROR *******found******* ~Salary() {delete * staff_id;} double getGrossPay() const {return base + bonus;} //返回应发项合计 double getNetPay() const {return getGrossPay() - tax;} //返回实发工资额 private: char * staff_id; //职工号 double base; //基本工资 double bonus; //奖金 double tax; //代扣个人所得税 }; int main() { Salarypay("888888", 3000.0, 500.0, 67.50); cout << "应发合计:" << pay.getGrossPay() << " "; cout << "应扣合计:" << pay.getGrossPay() - pay.getNetPay() << " "; // ERROR *******found******* cout << "实发工资:" << pay::getNetPay() << endl; return 0; }
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成构造函数的定义,使得数据成员变量filename和codex为空,内容长度FileLength为0。请在注释//********1********后添加适当的语句。 (2)完成析构函数,对contex内存的释放。请在注释//********2********后添加适当的语句。 (3)完成WriteFile()函数,用来对contex内容进行设置填充内容,如果以前有内容,则删除以前的内容,重新填写。请在注释//********3********后添加适当的语句。 (4)完成CopyFile()函数,完成将参数对象的contex的内容拷贝到当前的文件内容中,请在注释//********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include<iostream.h> class MyFileClass { private: char filename[64]; char* contex; int FileLength; public: MyFileClass() //********1******** contex=NULL; FileLength=0; } ~MyFileClass() { if(FileLength) //********2******** } void OpenFile(char* str, int len) { for(int i=0;i<len;i++) { filename [i]=str [i]; } filename [len]=0; FileLength=0; if (contex) { delete [] contex; contex=NULL; } } void WriteFlie(char* str, int len) { if(contex !=NULL) //********3******** contex=new char [len+1]; for(int i=0;i<len;i++) contex[i]=str[i]; contex[len]=0; FileLength=len; } void CopyFile(MyFileClass } }; int main () { MyFileClass file1,file2; file1.OpenFile ("txt1", 4); file2.OpenFile ("txt2", 4); file1.WriteFlie ("hello!",6); file2.CopyFile (file1); file1.display(); file2.display(); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开 proj2下的工程proj2,其中定义了vehicle类,并派生出motorcar类和bicycle类。然后以motorcar和bicycle作为基类,再派生出motorcycle类。要求将vehicle作为虚基类,避免二义性问题。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 80 150 100 1 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include<iostream. h> class vehicle { private: int MaxSpeed; int Weight; public: //**********found********** vehicle(int maxspeed, int weight):______ ~vehicle() {}; int getMaxSpeed() {return MaxSpeed;} int getWeight() {return Weight;} }; //**********found********** class bicycle:______public vehicle { private: int Height; public: bicycle(int maxspeed, int weight, int height): vehicle(maxspeed, weight), Height(height) {} int getHeight() {return Height;}; }; //**********found********** class motorcar:______public vehicle { private: int SeatNum; public: motorcar(int maxspeed, int weight, int seatnum): vehicle(maxspeed, weight), SeatNum(seatnum) {} int getSeatNum() {return SeatNum;}; }; //**********found********** class motorcycle:______ { public: motorcycle(int maxspeed, int weight, int height): vehicle(maxspeed, weight), bicycle(maxspeed, weight, height), motorcar(maxspeed, weight, 1) {} }; void main() { motorcycle a(80, 150, 100); cout<<a. getMaxSpeed()<<endl; cout<<a. getWeight()<<endl; cout<<a. getHeight()<<endl; cout<<a. getSeatNum()<<endl; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出: 1,2,3,4,5, 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。#include<iostream.h>class TestClass{ //********error******** TestClass(int i) { m_i = i; } void print() { cout<<++m_i<<','; }public: int m_i;};int main(){ //********error******** int i(); TestClass data(0); while(i>5) { //********error******** i++; data.print(); } cout<<end1; return 0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程包含有一个源程序文件proj2.cpp,其中定义了Stack类和ArrayStack类。stack是一个用于表示数据结构“栈”的类,栈中的元素是字符型数据。Stack为抽象类,它只定义了栈的用户接口,如下所示:公有成员函数功能push入栈:在栈顶位置添加一个元素pop退栈:取出并返回栈顶元素ArrayStack是Stack的派生类,它实现了Stack定义的接口。ArrayStack内部使用动态分配的字符数组作为栈元素的存储空间。数据成员maxSize表示的是栈的最大容量,top用于记录栈顶的位置。成员函数push和pop分别实现具体的人栈和退栈操作。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述功能。此程序的正确输出结果应为:a,b,Cc,b,a注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。//proj2.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=______________;}~ArrayStaek(){//********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]<<end1;sRef.push(ch[0]);sRef.push(ch[1]);sRef.push(ch[2]);cout<<sRef.pop()<<",";cout<<sRef.poP()<<",";cout<<sRef.poP()<<end1;}int main(){ArrayStack as(10);f(as);return0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,该工程中含有一个源程序文件proj2.cpp,请将堆栈类的定义补充完整。使程序的输出结果为: The element of stack are:4 3 2 1 注意:请勿修改主函数main和其他函数中的任何内容,只在横线处编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 //proj2.cpp #include <iostream> using namespace std; const int Size=5; class Stack; class Item public: //**********found********** Item(const int Item* next; friend class Stack; ; class Stack public: Stack():top(NULL) ~Stack(); int Pop(); void Push(const int private: Item*top; : Stack::~Stack() Item*p=top,*q; while(p!=NULL) q=p->next; //**********found********** ______;//释放p所指向的节点 p=q; int Stack::Pop() Item* temp; int ret; //**********found********** ______;//使temp指向栈顶节点 ret=top->item; top=top->next; delete temp; return ret; void Stack::Push(const int //**********found********** ______; //使新节点的next指针指向栈顶数据 top=temp; int main () Stack s; for(int i=1;i<Size;i++) s.Push(i); cout<<"The element of stack are:"; for(i=1;i<Size;i++) return 0;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: number1=a number2=a number1=a number2=b 注意:错误的语句在∥********error********的下面,修改该语句即可。 #include class CMyClass { public: ∥********error******** friend void SetValue(CMyClas 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=”<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: 每卖出一个瓜,则计算瓜的重量,还要计算所有卖出瓜的总重量以及总个数,同时允许退货,请按照以下的操作,把类补充完整 (1)定义类Cmelon的私有静态数据成员float型变量totalweight和int型变量totalNo,请在注释//********1********后添加适当的语句。 (2)完成类Cmelon的带一个float型变量w的构造函数,并把这个w加到totalweight中,并且totalNo自加。请在注释//********2********后添加适当的语句。 (3)在析构函数中,在totalweight中减去weight,然后totalNo自减,请在注释//********3********后添加适当的语句。 (4)完成静态成员变量的初始化为0,请在注释//********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>Class Cmelon{private: float weight; //********1******** static int totalNo;public: Cmelon(fleat w) { //********2******** totalweight+=w; totalNo++; } ~Cmelon() { //********3******** totalweight-=weight; } void display() { cout<<"Sell a melonwith"<<weight<<”kg”<<endl; cout << "Total Sellnumber:"<<totalNo<<endl; cout << "Total sellweight:"<<totalweight<<"kg"<<endl<<endl; }};//********4********float Cmelon::totalweight=0.0;int main(){ Cmelon melon1(1.2); melon1.display(); Cmelon melon2(2.3); melon2.display(); return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int x),该函数功能是判定x的所有的约数,并且在函数中调用写函数WriteFile0将结果输出到modi2.txt文件中。 例如:x=10的约数为1,2,5,10。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构. #include #include #include using namespace std ; void WriteFile(int c) { ofstream outl ; outl.open(”modi2.txt”,ios— base::binary I los—base::app); outl<
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,该工程中包含程序文件main.cpp,其中有类Door(“门”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:打开503号门…门是锁着的,打不开。打开503号门的锁…锁开了。打开503号门…门打开了。打开503号门…门是开着的,无须再开门。锁上503号门…先关门…门锁上了。注意:只修改每个“//ERROR**********found**********”下的那一行,不要改动程序中的其他内容。#include<iostream>using namespace std;class Door{int num;//门号bool closed;//true表示门关着bool locked;//true表示门锁着public:Door(int num){//ERROR**********found**********sum=this->num;closed=locked=true;}bool isClosed()const{return closed;}//门关着时返回true,否则返回falsebool isOpened()const{return!closed;}//门开着时返回true,否则返回falsebool isLocked()const{return locked;}//门锁着时返回true,否则返回falsebool isUnlocked()const{return!locked;}//门未锁时返回true,否则返回falsevoid open(){//开门cout<<endl<<"打开"<<num<<"号门…";//ERROR**********found**********if(closed)cout<<"门是开着的,无须再开门。";else if(locked)cout<<"门是锁着的,打不开。";else{closed=false;cout<<"门打开了。”;}}void close(){//关门cout<<endl<<"关上"<<num<<"号门…";if(closed)cout<<"门是关着的,无须再关门。";else{closed=true;cout<<"门关上了。";}}//ERROR**********found**********void lock()const{//锁门cout<<endl<<"锁上"<<hum<<"号门…";if(locked)cout<<"门是锁着的,无须再锁门。";else{if(!closed){cout<<"先关门…";closed=true;}locked=true;cout<<"门锁上了。";}}void unlock(){//开锁cout<<endl<<"开"<<Hum<<"号门的锁…";if(!locked)cout<<"门没有上锁,无须再开锁。";else{locked=false;cout<<"锁开了。";}}};int main(){Door door(503);door.open();door.unlock();door.open();door.open();door.lock():return0;}
进入题库练习
问答题使用VC6打开下的源程序文件modi2.cpp。请完成函数fun(inti),实现以下功能:当i等于5时,则打印如下内容。###############注意:不能修改程序的其他部分,只能修改fun()函数。#include<iostream.h>voidfun(intn){}voidmain(){intn;cout"请输入打印的行数:"endl;cinn;if(n<i){cout"输入的行数必须大于0"endl;return;}fun(n);return;}
进入题库练习
问答题简单应用题 请编写函数fun(),该函数的功能是判断字符串是否为回文,若是则函数返回1,主函数中输出YES;否则返回0,主函数中输出NO。回文是指顺读和倒读都一样的字符串。 例如:字符串LEVEL是回文,而字符串123312就不是回文。 注意:部分源程序已存在文件kt11_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 文件kt11_2.cpp的内容如下: #include #include #defineN80 intfun(char*str) { } voidmain() { chars[N]; cout<<"Enterastring:"<
进入题库练习
问答题简单应用题 编写函数fun(),该函数的功能是从字符串中删除指定的字符,同一字母的大、小写按不同字符处理。 例如:程序执行时输入字符串为turbo c and borland c++,从键盘上输入字符n,则输出后变为turbo c ad borlad c++。 如果输入的字符在字符串中不存在,则字符串照原样输出。 注意:部分源程序已存在文件test18_2.cpp中。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 文件test18_2.cpp的内容如下: #include #include #include void fun(char s[ ], int c) { } void main() { static char str[ ]="turbo c and borland c++"; char ch; cout>ch; fun(str,ch); cout<<"str="<
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生目录proj3下的工程文件proj3,此工程中包含一个源程序文件proj3.cpp,补充编制C++程序proj3.cpp,其功能是读取文本文件in.dat中的全部内容,将文本存放到doc类的对象myDoc中。然后将myDoc中的字符序列反转,并输出到文件out.dat中。文件in.dat的长度不大于1000字节。 要求: 补充编制的内容写在“//**********333**********”与“**********66666**********”两行之间。实现将myDoc中的字符序列反转,并将反转后的序列在屏幕上输出。不得修改程序的其他部分。 注意:程序最后已将结果输出到文件out.dat中,输出函数writeToFile已经给出并且调用。 //proj3.cpp #include<iostream> #include<fstream> #include<cstring> using namespace std; class doc private: char*str;//文本字符串首地址 int length;//文本字符个数 public: //构造函数,读取文件内容,用于初始化新对象,filename是文件名字符串首地址 doc(char*filename); void reverse();//将字符序列反转 ~doc(); void writeToFile(char*filename); ; doc::doc(char*filename) ifstream myFile(filename); int len=1001,tmp; str=new char[len]; length=0; while((tmp=myFile.get())!=EOF) str[length++]=tmp; str[length]='/0'; myFile.close(); void doc::reverse() //将数组str中的length个字符中的第一个字符与最后一个字符交换,第二个字符与倒数第二个 //字符交换…… //*************333************* //*************666************* doc::~doc() delete[]str; void doc::writeToFile (char *filename) ofstream outFile (filename)j outFile<<str; outFile.close(); void main() doc myDoc("in.dat¨); myDoc.reverse(); myDoc.writeToFile("out.dat");
进入题库练习
问答题使用VC6打开考生文件夹下的工程MyProj7。此工程包含一个源程序文件MyMain7.cpp。其中定义了类Sample,但类Sample的定义并不完整。 请按要求完成下列操作,将类Sample的定义补充完成: ①定义私有数据成员n,它是int型的数据。请在注释“//* *1**”之后添加适当的语句。 ②完成重载构造函数Sample()的定义,使Sample对象的默认值:n=0。请在注释“//* *2* *”之后添加适当的语句。 ③完成成员函数add()的类体内的定义,使成员函数返回的Sample对象的值n为两类Sample对象s1和s2的私有成员n的和。请在注释“//* *3* *”之后添加适当的语句。 ④完成成员函数disp()的类外定义,使其以“n=”的格式将Sample对象的值输出到屏幕上。请在注释“* *4* *”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件MyMain7.cpp清单如下: //MyMain7.cpp #include<iostream> using namespace std; class Sample private: //* * 1* * public: Sample() //* *2* * Sample add(Sample s1,Sample s2) //* *3* * void disp(); ; void Sample: :disp() //* * 4 * * int main() Sample s1(10),s2(5),s3; cout<<"s1:"; s1.disp(); cout<<"/n S2:"; s2,disp(); s3.add(s1,S2); cout<<"/n s3.add(s1,s2)/n s3:"; s3.disp(); return 0;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:151注意:错误的语句在//******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;}
进入题库练习