计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示日期的类Date,但类Date的定义并不完整。请按要求完成下列操作,将类Date的定义补充完成。 (1)定义私有数据成员year、month和day,分别用于表示年、月和日,它们都是int型的数据。请在注释//********1********之后添加适当的语句。 (2)完成默认构造函数Date的定义,使Date对象的默认值为:year=1,month=1,day=1,请在注释//********2********之后添加适当的语句。 (3)完成重载构造函数Date(int y,int m,int d)的定义,把数据成员year、month和day分别初始化为参数y、m和d的值,请在注释//********3********后添加适当的语句。 (4)完成成员函数print()的类外定义,使其以“年一月一日”的格式将Date对象的值输出到屏幕上,例如:2008-8-8。请在注释//********4********之后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>class Date{public: //********2******** Date(int y,int m,int d) { //********3******** } void print()const;private: //data member //********1********};void Date::print()const{ //********4******** } int main(){ Date national_day(1949,10,1); national_day.print(); 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打开考生文件夹下的源程序文件mod12.cpp。请完成函数fun(intx),该函数功能是将x的值转换成二进制数输出到屏幕,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。 例如:x=13, 13的二进制数字为1101,则输出到屏幕的为1101。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 #inc1ude <iostream> #inc1ude<fstream> #inc1ude<cmath> using namespace std; void Wr:iteFile(char* str) { ofstream outl; outl.open("modi2.txt",ios_ base::binarylios_base::app); for(int i=0; str[i]!=0;1++) outl.put(str[i]); outl.c1ose(); } void fun(int x) { } void ClearFile() { ofstream outl; out1,open("modi2.txt"); outl.c1ose(), } int main() { ClearFile(); fun(13); return0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个程序文件main.cpp,其中有坐标点类point、线段类Line和三角形类Triangle的定义,还有main函数的定义。程序中两点间距离的计算是按公式实现的,三角形面积的计算是按公式实现的,其中。请在程序中的横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为:Side1:9.43398Side2:5Side3:8area:20注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include#includeusingnamespacestd;classPoint{//坐标点类public:constdoubleX,Y;Point(doubleX=0.0,doubleY=0.0):x(X),Y(y){)//**********found**********doubledistanceTo(_______)const{//到指定点的距离returnsqrt((x—P.X)*(x—P.x)+(y—P.y)*(y—P.y));}};classLine{//线段类public:constPointp1,p2;//线段的两个端点//**********found**********Line(Pointp1,Pointp2):_______{}doublelength()const{returnp1.distanceTo(p2);)//线段的长度};classTriangle{//三角形类public:constPointp1,p2,p3;//三角形的三个顶点//**********found**********Triangle(______):p1(p1),p2(p2),p3(p3){)doublelengthl()const{//边p1,p2的长度returnLine(p1,p2).length();}doublelength2()const{//边p2,p3的长度returnLine(p2,p3).length();}doublelength3()const{//边p3,p1的长度returnLine(p3,p1).length();}doublearea()const{//三角形面积//**********found**********doubleS=_______;returnsqrt(S*(S—lengthl())*(S—length2())*(S—length3()));}};intmain(){Triangler(Point(0.0,8.0),Point(5.0,0.0),Point(0.0,0.0));cout
进入题库练习
问答题使用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& obj){ //********4********}int main(){ obj A1 obj0(10); cout<<func(obj0)<<end1; return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.epp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:1063022 注意:错误的语句在//*****error******的下面,修改该语句即可。#include<iostream.h>class CMyClass{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: CMyClass() { func[0]=CMyClass::Add; func[1]=CMyClass::Sub; func[2}=CMyClass::Mul; func[3]=CMyClass::Div; number=0; } int CallFunction(int i,int j) { //*****error****** return(func[i])(j); }};void main(){ CMyClass myobj; cout<<myobj.CallFunction(0,10)<<end1; cout<<myobj.CallFunction(1,4)<<end1; cout<<myobj.CallFunction(2,5)<<end1; cout<<myobj.CallFunction(3,15)<<end1; cout<<myobj.CallFunction(3,0)<<end1;}
进入题库练习
问答题综合应用题 使用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 #include 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 > a >> b; CPosition psA(a, b); cout > a >> b; cout << "The distance is " << psA.distance(a,b) <
进入题库练习
问答题请编写一个函数char *fun(char *s),其中s代表一个字符串。函数fun()的功能是将字符串s的元素倒置。例如,输入为“teacher”,则应输出“rehcaet”。 注意:部分源程序已存在文件PROC10.cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。 文件PROC10.cpp的内容如下: //PROC10. cpp #include <iostream> #include <string> using namespace std; char *fun(char *s); int main ( ) char str[81]; cout<<"Please enter a string:/n"; cin>>str; cout<<"The result is:"<<fun(str)); cout<<end1; return 0; char*fun(char*s) //* * * * * * * * *
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完整。   (1)定义私有数据成员leftPoint、topPoint、rightPoint、bottomPoint,分别用于表示矩形左上角及右下角的点的坐标,它们都是double型的数据。请在注释1之后添加适当的语句。   (2)完成默认构造函数CRect的定义,指定默认实参为0,它们都是double型的数据。请在注释2之后添加适当的语句。   (3)定义函数体为空的析构函数。请在注释3之后添加适当的语句。   (4)在main函数中定义GReet类的实例rect2,并把re-   ct1的值赋给rect2。请在注释4之后添加适当的语句。   注意:除在指定位置添加语句之外,不要改动程序中的其他内容。   试题程序:   #include   classCRect   {   private:   //********1********   public:   //********2********   //********3********   voidSetPoints(double,double,double,double);   voidSetLeftPoint(doublem){leftPoint=m;}   voidSetRightPoint(doublem){rightPoint=m;}   voidSetTopPoint(doublem){topPoint=m;}   voidSetBottomPoint(doublem){bottomPoint=m;}   voidDisplay();   };   CReet::CRect(double1,doublet,doubler,doubleb)   {   leftPoint=1;topPoint=t;   rightPoint=r;bottomPoint=b;   }   voidCRect::Setpoints(double1,doublet,doubler,doubleb)   {   leftPoint=1;topPoint=t;   rightPoint=n;bottomPoint=b;   }   voidCRect::Display()   {   cout<<"left-toppointis("<  Point<<")"<<’\n’;   cout<<"right-bottompointis("<  <  }   voidmain()   {   CRectrect0;   rect0.Display();   rect0.SetPoints(20,20.6,30,40);   rect0.Display();   CRectrectl(0,0,150,150);   rect1.SetTopPoint(10.5);   rect1.SetLeftPoint(10.5);   //********4********         rect2.Display(  );}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成类Rect的构造函数,实现对变量left、fight、top、bottom的初始化,缺省值都为0,请在注释∥********1********后添加适当的语句。 (2)完成类Rectangle的构造函数,请在注释∥********2********后添加适当的语句。 (3)完成计算矩形对角线长度函数Diagonal 0,请在注释∥********3********后添加适当的语句。 (4)完成计算周长函数Girth(),请在注释∥********4********后添加适当的语句。 程序输出: 50 140 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include #include class Rectangle { public: int left t right l top l bottom; ∥********1******** { left=1; right=r; top=t ; bottom=b; } ∥********2******** { 1eft=rc.1eft; right=rc.right; top =rc.top ; bottom=rc.bottom; } float Diagonal() { ∥********3******** return } int Girth() { ∥********4******** return } }; int main() { Rectangle rect(20,50,40,80); Rectangle rect2(rect); cout<
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1。其中有线段类Line的定义。程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: End point 1=(1,8),End point 2=(5,2),length=7.2111。 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> #include <cmath> using namespace std; class Line; double length(Line); class Line //线段类 double x1,y1; //线段端点1 double x2,y2; //线段端点2 public: //ERROR **********found********** Linedouble x1,double y1,doublex2,double y2)const this->x1=x1; this->y1=y1; this->x2=x2; this->y2=y2; double getX1()constreturn x1; double getY1()constreturn y1; double getX2()constreturn x2; double getY2()constreturn y2; void show () const cout<<"End point 1=("<<x1<<","<<y1; cout<<"),End point 2=("<<x2<<","<<y2; //ERROR ********found******** cout<<"),length="<<length(this) <<"。"<<endl; ; double length (Line 1) //ERROR ********found******** return sqrt((1.x1-1.x2)*(1.x1-1.x2)+(1.y1-1.y2)*(1.y1-1.y2)); int main () Line r1(1.0,8.0,5.0,2.0); r1.show(); return 0;
进入题库练习
问答题使用VC6打开下的源程序文件modi2.cpp。完成空出的函数fun(inta[],int*index),使函数输入n(<100)个整数到指定数组,求该数组中最大元素的值和此元素的下标,最大元素值以函数值返回,此元素的下标通过指针形参带回调用函数。要求函数实现以下的功能:(1)获得输入的n个整数;(2)把最大的数字的下标在第二个参数中输出;(3)把最大的数字作为返回值。注意:不能修改程序的其他部分,只能修改fun()函数。#include<iostream.h>#defineMAXLINE100intfun(inta[],int*index){}voidmain(){intA[MAXLINE];intindex;intmaxdata;maxdata=fun(A,cout"themaxdatais:"maxdata"""theposionis:"indexendl;return;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程中含有一个源程序文件proj2.cpp,请编写一个函数int huiwen(int n),用于求解所有不超过200的n值,其中n的平方是具有对称性质的回文数(回文数是指一个数从左向右读与从右向左读是一样的,例如:34543和1234321都是回文数)。求解的基本思想是:首先将n的平方分解成数字保存在数组中,然后将分解后的数字倒过来再组成新的整数,比较该整数是否与n的平方相等。 注意:请勿修改主函数main和其他函数中的任何内容,只在横线处编写适当代码,也不要删除或移动“//****found****”。 //proj2.cpp #include <iostream> using namespace std; int huiwen(int n) { int arr[16], sqr, rqs=0, k=1; sqr =n*n; for(int i=1; sqr!=0; i++) { //******** found******** ______; sqr/ =10; } for(;i>1; i--) { rqs+ =arr[i-1]* k; //******** found******** ______; } //******** found******** if(______) return n; else return 0; } int main () { int count =0; cout <<"The number are: "<<endl; for(int i=10; i<200; i++) if(huiwen(i)) cout << ++count <<'/t'<<i<<'/t'<<i* i<<endl; return 0; }
进入题库练习
问答题使用VC6打开 下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序,使输入某年某月某日,可判断这一天是这一年的第几天。 程序分析:以3月5日为例,应该先把前两个月的天数加起来,然后再加上5天即本年的第几天(特殊情况:闰年输入月份大于3时需考虑多加一天)。 注意:只能补充函数func(int year,int month,int day),请勿改动其他部分的内容。 #include <iostream.h> int func (int year,int month, int day) { } void main() { cout func(2007,2,1) endl; cout func(2007,10,10) endl; cout func(2008,8,12) endl; return; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程中含有一个源程序文件proj2.cpp,其中定义了MyString类。MyString是一个用于表示字符串的类,其构造函数负责动态分配一个字符数组,并将形参指向的字符串复制到该数组中;成员函数reverse的功能是对字符串进行反转操作,例如,字符串“ABCDE”经过反转操作后,会变为“EDCBA”;成员函数print的作用是将字符串输出到屏幕上。 请在横线处填写适当的代码并删除横线,以实现MyString类的功能。此程序的正确输出结果应为: Before reverse: abc defg After reverse: cha gfed 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 //proj2.cpp #include <iostream> using namespace std; class MyString { public: MyString (const char* s) { //********** found********** m_str = new char[______]; strcpy (m_str, s) ; } ~MyString () { //********** found********** ______; } void reverse () { int n = strlen(m str) ; for (int i=0; i < n/2; ++i) { int tmp = m_str[i]; //********** found********** m_str[i] = ______; //********** found********** ______; } } void print () { cout << m_str << endl; } //其他成员... private: char* m_str; }; int main(int argc, char * argv[]) { MyString str1 ("abc"), str2 ("defg"); cout << "Before reverse: /n"; str1.print (); str2.print (); str1.reverse (); str2.reverse (); cout << "After reverse: /n"; str1.print (); str2.print (); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹pmj1下的工程pmj1,其中有点类Point和线段类Line和主函数main的定义,程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出应为:pl=(8,4)p2=(3,5)注意:只修改两个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>#include<cmath>usingnamespacestd;clasSPoint{doublex,y;public:Point(doublex=0.0,doubley=0.0)//ERROR**********found**********{x=x;y=y;)doublegetX()const{returnx;}doublegetY()const{returny;)//ERROR**********found**********voidshow()const{cout<<'('<<x<<','<<Y<<')')};clasSLine{Pointp1,p2;public:Line(Pointpt1,Pointpt2)//ERROR**********found**********{pt1=p1;pt2=p2;)PointgetP1()const{returnp1;)PointgetP2()const{returnp2;)};intmain()(Lineline(Point(8,4),Point(3,5));cout<<"p1=";line.getP1().show();cout<<"p2=";line.getP2().show();cout<<end1;return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数convert(char*strOct)的功能是将八进制转换为十进制。提示:要每一位转换,然后把转换后得到的数累加起来即可。注意:不能修改其他部分的代码。#include<iostream.h>#include<cmath>int convert(char* StrOct){}int main(){cout<<convert("7")<<endl;cout<<convert("10")<<endl;cout<<convert("1234")<<endl;return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int i),实现以下功能:当i等于5时,则打印如下内容。 # ## ### #### ##### 注意:不能修改程序的其他部分,只能修改fun()函数。 #include void fun(int n) { } void main() { int n; cout>n; if(n<1) { cout<<“输入的行数必须大于0”<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数convert(char*des,char*str)的功能是去掉字符串str中相同的字母,并将处理后的结果存到des所指的字符串中。例如: 输入:This is great! 输出:This grea! 注意:不能修改程序的其他部分,只能补充fun()函数。 #include #define MAXLEN 1024 Void convert(char*des,char* str) { } void main() { char sour[MAXLEN]; char dest[MAXLEN]; cout<<"Please input a string: "<
进入题库练习
问答题请编写一个函数void swap(int *x,int*y),用来交换两个数的值。 注意:部分源程序已存在文件test14_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数swap的花括号中填写若干语句。 文件test14_2.cpp的内容如下: #include<iostream.h> void swap(int *x,int*y); void main() int a=1,b=3; swap(&a,&b); cout<<"a="<<a<<" "<<"b="<<b<<endl; void swap(int *x,int *y)
进入题库练习