计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成构造函数的定义,使得数据成员变量filename和contex为空,内容长度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,intlen) { 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&file) { //********4******** } void display() { cout<<contex<<end1; }};int main(){ MyFileClass file1,file2; filel.OpenFile("txt1",4); file2.OpenFile("txt2",4); file1.WriteFlie("hello",6); file2.CopyFile(file1); file1.display(); file2.display(); return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序,使该程序输出倒9×9口诀。程序分析:分行与列考虑,共9行9列,设置两个变量i和i,i控制行,j控带0列。程序运行结果如下:1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=811*8=8 2*8=16 3*8=24 4*8=32 5*8=40 6*8=48 7*8=56 8*8=641*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=491*6=6 2*6=12 3*6=18 4*6=24 5*6=30 6*6=361*5=5 2*5=10 3*5=15 4*5=20 5*5=251*4=4 2*4=8 3*4=12 4*4=161*3=3 2*3=6 3*3=91*2=2 2*2=41*1=1注意:只能补充函数show(),请勿改动其他部分的内容。#2nclude<iostream.h>void show(){}void main(){cout<<"9*9倒乘法口诀"<<endl;cout<<"-----------------------------------------------"<<endl;show();tout<<"-----------------------------------------------"<<endl;return;}
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数un(char*str1,char*str2),此函数的功能是计算str1中出现str2的个数,当不出现时,则返回0。 如 str1为“asdfsfdfg” str2为“sf”则返回1 str2为“df”则返回3 注意:不能修改函数的其他部分。 试题程序: #include<iostream.h> //注意只能使用int类型,不能类型转换 int fun(char*str1,char*str2) void main() char str1[l024]; char str21256]; cout<<"please input a string:"<<end1; cin.getline(str1,1024); cout<<"please input other string:"<<end1; cin.getline(str2,256); cout<<fun(str1,str2); cout<<end1; return;
进入题库练习
问答题使用VC6打开考生文件夹下的工程test14_1,此工程包含一个源程序文件test14_1.cpp,但该程序运行有问题,请改正程序中的错误,使该程序的输出结果如下: member1=5 member2=5 member1=7 member2=9 源程序文件test14_1.cpp清单如下: #include<iostream.h> class My Class /************** found ***************** friend void setMember(MyClass myObj,char meml) myObj.member1=mem1; myObj.member2=mem1; cout<<"member1="<<myObi.member1<<" member2="<<myObj.member2<<endl; /************** found ***************/ void setMember(MyClass& myObj,char mem1,char mem2) myObj.member1=mem1; myObj.member2=mem2; cout<<"member1:"<<myObj.member1<<"member2="<<myObj.member2<<endl; private: char member1; char member2; ; void main() MyClass theObj; /************** found ****************/ theObj.setMember(theObj,'5'); theObj.setMember(theObj,'7','9');
进入题库练习
问答题使用VC6打开考生文件夹下的工程test12_3,此工程包含一个test12_3.cpp,其中定义了类Base和类A,类A公有继承 Base,但这两个类的定义都并不完整。请按要求完成下列操作,将程序补充完整。 (1)定义枚举类型变量en,它包含两个枚举符front和back,请在注释“//**1**”之后添加适当的语句。 (2)在类Base中添加常成员虚函数void E()的定义,该函数输出“In Base E!”,请在注释“//**2**”之后添加适当的语句。 (3)在类A中添加常成员虚函数void E()的定义,该函数先调用基类中的虚函数 E()再输出“In AE!”,请在注释“//** 3**”之后添加适当的语句。 (4)完成类A构造函数的定义,请使用参数列表的形式初始化类A的成员,并输出“A constructor.”,请在注释“//** 4**”之后添加适当的语句。 输出结果如下: Base constructor. A constructor. In BaseE! In AE! In BaseP! In A! 1 A destructor. Base destructor. 注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。 源程序文件test12_3.cpp清单如下: #include<iostream .h> // ** 1 ** class Base protected: int b1; int b2; public: Base(); ~Base(); int Getb1()const return b1; void Setb1(int x) b1 = x; int Getb2()const return b2; void Setb2(int y) b2 = y; void Print()const cout<<"In Base P!"<<end1;    // ** 2 ** ; Base::Base():b1(1),b2(5) cout<<"Base constructor."<<endl; Base::~Base() cout<<"Base destructor."<<endl; class A:public Base protected: en enA; public: A(); ~A(); en GetColor()const return enA; void SetColor(en color) enA = color; void InA()cout<<"In A!"<<endl; // ** 3 ** Base::E(); cout<<"In AE!"<<endl; ; // ** 4 ** cout<<"A constructor."<<endl; A::~A() cout<<"A destructor."<<endl; void main() A a1; a1.E(); cout<<endl; a1.Print(); a1.InA(); cout<<a1.Getbl()<<endl;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 5 1 注意:错误的语句在∥********error********的下面,修改该语句即可。 #include ∥********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 strl; strl.Fri=Mon; cout<
进入题库练习
问答题使用VC6打开考生文件夹下的工程test28_3。此工程包含一个test28_3.cpp,其中定义了类Person,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。 (1)定义类Person的私有数据成员forename、surname 和 money,forename 和 surname都是char型的指针数据,money是double型的数据。请在注释“//**1**”之后添加适当的语句。 (2)完成类Person的带三个参数的构造函数Person(char *f, char *s,double m),分别为forename和surname申请新的空间来存储参数f和s指针指向的内容,注意空间的大小,最后把参数m的值赋给money,请在注释“//**2**”之后添加适当的语句。 (3)完成类Person的析构函数的定义,把forename和surname指向的空间释放,请在注释“//**3**”之后添加适当的语句。 (4)完成类Person的成员函数display的定义,使其以格式“forname surname has money”的形式输出内容,请在注释“//**4*。”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 输出结果如下: Richard Berk has 1000.56 源程序文件test28_3.cpp清单如下: #include <iostream.h> #include <string.h> class Person private: //** 1 ** double money; public: Person(char *f, char *s, double m); ~Person(); void display(); ; Person::Person(char *f, char *s, double m) //** 2 ** strcpy(forename, f); surname = new char[strlen(s)+1]; strcpy(surname, s); money=m; Person: :-Person () //** 3 ** void Person:: display ( ) //** 4 ** void main ( ) Person p("Richard", "Berk", 1000.56); p.display ( );
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数fun(int N[4])的功能是用4个数字,组成互不相同且无重复数字的三位数,并将满足所有条件的数字输出到屏幕,并且每输出一个三位数字就换一行。 程序分析:可填在百位、十位、个位的数字都是1、2、3、0。组成所有的排列后再去掉不满足条件的排列。如果判定第一个数字是0则也去掉。 #include void fun(int N[4]) { } int main() { int N[4]={1,2,3,0}; fun(N); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的工程test11_3。此工程包含一个test11_3.cpp,其中定义了类CPosition,但该类的定义都并不完整。请按要求完成下列操作,将类CPosition的定义补充完整。 (1)在类定义外完成重载的两个构造函数CPosition()和CPosition(double dx,double dy),其中前者为不带参数的构造函数,使CPosition对象的默认值为x=0,y=0,后者为带参数的构造函数,把数据成员x和y分别初始化为参数dx和dy的值。请在注释“//**1**”之后添加适当的语句。 (2)在类体中添加函数move(double ax,double ay)的定义,使得点的坐标x和y分别移动ax和ay个单位,请在注释“// **2**”之后添加适当的语句。 (3)完成函数double distance (double bx,double by)的定义,该函数返回*this和点(bx,by)的距离,请在注释“//**3**”之后添加适当的语句。 注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。 源程序文件test11_3.cpp清单如下: #include<iostream.h> #include<math.h> class CPosition public: CPosition(); CPosition(double dx,double dy); double getx(); double gety(); // ** 2 ** double distance(double bx,double by); private: double x; double y; ; // ** 1 ** x=0;y=0; CPosition::CPosition(double dx,double dy) x=dx;y=dy; double CPosition::getx() return x; double CPosition::gety() return y; double CPosition::distance(double bx,double by) // ** 3 ** void main() double a,b; cout << "Input x, y position of a point:"; cin >> a >> b; CPosition psA(a,b); cout << “Input x,y position of another point:"; cin >> a >> b; cout << "The distance is " << psA.distance(a,b) <<endl;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int x),该函数功能是将x的值转换成二进制数输出到屏幕,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。 例如:x=13,13的二进制数字为1101,则输出到屏幕的为1101。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。#include<iostream>#include<fstream>#include<cmath>using namespace std;void WriteFile(char*str){ orstream out1; out1.open(''modi2.txt",ios_base::binary|ios._base::app); for(int i=0;str[i]!=0;i++) out1.put(str[i]); out1.close(); } void ftm(int x) { } void ClearFile() { ofstream out1; out1.open(''modi2:txt''); out1.close(); } intmain() { ClearFile(); fun(13); return 0;}
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(char *data),此函数的功能是找出字符串数组中最大的ASCⅡ值,如果有相同变量,则输出最后一个所在的位置;如果字符串为空,则返回-1;或者不存在时也返回-1。 注意:不能修改函数的其他部分。计算数字如果第一个字母最大,则返回0。依次增加。 试题程序: #include<iostream.h> int fun(char *data) void main() char source[1024]; cout<<"请输入一行英文字符串:/n"; cin.getline(source,1024); cout<<"最大的字母出现在距离头部"<<fun(source)<<"个字母处"<<end1;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)对文件以追加的方式打开文件。请在注释//********1********后添加适当的语句。 (2)定义m、n为类TestClass的公有int型数据成员,请在注释//********2********后添加适当的语句。 (3)定义P为类TestClass的数据成员指针,并指向类TestClass数据成员m,请在注释//********3********后添加适当的语句。 (4)定义P指向类TestClass数据成员n,请在注释//********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>#include<fstream>#include<iomanip>#include<cmath>using namespace std;Void WriteFile(int x){ ofstream out1; //********1******** out1.open("modi3.txt", ); out1<<X<< ' '; out1.close();}void ClearFile(){ ofstream out1; out1.open("modi 3.txt"); out1.Close();}Class TestClass{public: void disp() { cout<<"m="<<m<<endl; WriteFile(m); cout<<"n="<<n<<endl; WriteFile(n); } //********2********};Void main(){ //********3******** ClearFile(); TestClass a; a.*p=30; //********4******** a.*p=45; a.disp();}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 0 注意:错误的语句在∥********error********的下面,修改该语句即可。 #include struct Struct { union { int a; char C[4]; }; int b; ∥********error******** } void mein() { Struct m; ∥********error******** m.c[0]=0; m.c[1]=0; m.c[2]=0; ∥********error******** m.c[3]=1; m.b=m.c[3]; cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分的程序。实现函数sort(intA[],int n),用冒泡法将数组排序。 提示:所谓冒泡法,就是每次把相邻的两个数交换,较大的数交换到后面。这样下标从0到n-1的数与其后面相邻的数交换,可以把最大的数交换到数组的末端。进行n次下标从0到n-1的交换,则数组则会变成有序的,而且是由大到小的顺序。 注意:不能修改程序的其他部分,并且不能删除其他的部分,也不能修改程序的结构。#include<iostream.h>#define N 10void sort(int A[N],int n){}int main() { int A[N]={5,7,4,6,10,13,78,-4,9,20}; sort(A,10); for(int i=0;i<sizeof(A)/sizeof(int);i++) { cout<<A[i]<<' '; } cout<<end1; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的工程RevProj11。此工程包含一个源程序文件RevMain11.cpp,但在源程序文件中有错误。请改正程序中的错误,使它能得到正确结果。 注意,不得删行或增行,也不得更改程序的结构。 源程序文件RevMainll.cpp中的程序清单如下: //RevMainll.cpp #include<iostream> using namespace std; class point private: const int color; int x; int y; public: point(int x,int y,int c) this->x=x; this->y=y; color=c; void show() cout<<"x="<<x<<",y="<<y<<",color="<<color<<end1; ; int main() const point p(10,10,100); p.show(); return 0;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为: init TestClass del TestClass 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>class TestClass{ //********error******** //********error******** int TestClass(){cout<<"initTestClass"<<endl;}; //********error******** void~TestClass(){cout<<"delTestClass"<<endl;};};Void main(){ TestClass obj ; return;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)利用define定义常量TRUE为1,定义常量FALSE为0,请在注释//********1********后添加适当的语句。 (2)在类A2前增加A1的声明,请在注释//********2********后添加适当的语句。 (3)在类C1中声明友元函数bool func(A2 friend bool func(A2 public: A2 () m_A2 = FALSE; public: void setA2(bool n) { m_A2=n; } }; class A1 { private: bool m_A1; //********3******** public: A1 () { m A1=TRUE; } public: void setA1 (bool n) { m_A1=n; } }; bool func(A2 A1 obj1; cout func (obj0, obj1) endl; obj0.setA2 (TRUE); obj1.setA1 (TRUE); cout func (obj0, obj1) endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数sum(int A[NUM][NUM],int n)实现的功能是计算矩阵中所有非质数数字的和。提示:函数isPrime(int n)的功能是判定当前数字是否为质数,如果是则返回true。注意:不能修改程序的其他部分,只能修改sum()函数。#include<iostream.h>#include<cmath>#defime NUM 50int A[NUM][NUM]={ {1 0,1 3,5 9,7 0,6}, {2,4 0,8 9,92,9}, {1 4,5 5,7 1,1 1,1 9}, {7 9,68,8 3,97,1 0 1}, {1 02,1 0 0 0 1,2 3,4 5}};bool isPrime(int n){ if(n==1) return false; if(n==2) retumR true; for(int i=2; i<n/2;i++) { if(n%i==0) return false; } return true;}int sum(int A[NUM][NUM],int n){}int msin(){ cout<<sum(A,5)<<endl; return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义类的私有变量a、b,请在注释//********1********后添加适当的语句。 (2)完成类的构造函数,对变量a、b赋值,缺省两个变量值为1,在注释//********2********之后添加语句。 (3)完成打印函数display(),打印出“a*b=c”格式的一个乘法算式,在注释//********3********之后添加语句。 (4)补充主函数,使得打印9×9的乘法口诀。在注释//********4********后添加语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>class CMyFormula{private: //********1********public: //********2******** { this一>a=a; this->b=b; } void set(int x,int y) { a=x; b=y; } void display() { //********3******** } }; int main() { CMyFormula formular(1,1); for(int i=1;i<=9;i++) { //********4******** for(int j=1;j++) { formular.set(j,i); formular.display(); cout<<" "; } cout<<endl; } return 0;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp,要求编写一个CMyShape类,含有求面积求周长等纯虚函数。然后编写一个CMyRectangle类和CMyCircle类继承CMyShape,并实现求面积、求周长的两个函数。在main()函数中测试得到下面的结果: 在CMyShape类构函数造内 在CMyCircle类构造函数内 在CMyShape类构造函数内 在CMyRectangle类构造函数内 myCircle:Area=314.159 Girth=62.8319 myRectangle:Area=900 Girth=120 具体要求如下: (1)定义求面积纯虚函数,请在注释//********1********之处添加适当的语句。 (2)定义求周长纯虚函数,请在注释//********2********之处添加适当的语句。 (3)请在注释//********3********和//********4********之处添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include <iostream.h> #include <math.h> #define PI 3.1415926 class CMyPoint { public: int x, y; CMyPoint (int tx, int ty): x(tx),y(ty) {} }; class CMyShape { public: CMyShape(){cout "在CMyShape类构造函数内" endl;} //********1******** //********2******** protected: }; class CMyCircle: public CmyShape { public: CMyCircle(CMyPoint i,double j):CMyShape(),arcCenter(i), radius(j){ cout "在CMyCircle类构造函数内" endl; } double GetArea() { return PI*radius*radius; } double GetGirth() { return 2*PI*radius; } private: CMyPoint arcCenter; double radius; }; class CMyRectangle: public CmyShape { public: CMyRectangle(CMyPoint lt,CMyPoint rb):leftTop(lt), rightBottom(rb),CMyShape() { cout "在CMyRectangle类构造函数内" endl; } Double GetArea() { int width=abs (rightBottom.x-leftTop.x); int height=abs (rightBottom.y-leftTop.y); Return width*height; } double GetGirth() { int width=abs (rightBottom.x-leftTop.x); int height=abs (rightBottom.y-leftTop.y); return 2*(width+height); } private: CMyPoint leftTop, rightBottom; }; void main() { CMyShape *myShape=NULL; CMyCircle *myCircle=new CMyCircle(CMyPoint(5,5),10); CMyRectangle *myRectangle=new CMyRectangle(CMyPoint(0,0), CMyPoint(30,30)); //********3******** cout "myCircle: " "Area=" myShape->GetArea () "/t" "Girth=" myShape-> GetGirth() endl; //********4******** cout "myRect angle: " "Are a=" myShape->GetArea () "/t" "Girth=" myShape-> GetGirth() endl; }
进入题库练习