计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi2.clip。请完成函数fun(int x),该函数功能是将x的值转换成二进制数输出到屏幕,并且在函数中调用写函数WriteFile()结果输出到modi2.txt文件中。 例如:x=13,13的二进制数字为1101,则输出到屏幕的为1101。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 #include #include using namespace std; voidWriteFile(char*str) { orstrcam outl; out1.open("modi2.txt",ios_base∷binarylios_base∷app); for(int i=0;str[i]!=0;i++) out1.put(str[i]); out 1.close(); } void fun(int x) { } void ClearFile() { ofstream out1; out1.open("modi2.txt"); out1.close(); } intmain() { ClearFile(); fun(is); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生目录proj3下的工程文件proj3,该文件中定义了用于表示日期的类Date、表示人员的类Person和表示职员的类Staff;程序应当显示: 张小丽123456789012345 但程序中有缺失部分,请按以下提示把缺失部分补充完整: (1)在“//**1** ****found****”的下方是析构函数定义中的语句,它释放两个指针成员所指向的动态空间。 (2)在“//**2** ****found****”的下方是rename函数中的一个语句,它使指针name指向申请到的足够容纳字符串new_name的空间。 (3)在“//**3** ****found****”的下方是构造函数定义的一个组成部分,其作用是利用参数表中前几个参数对基类Person进行初始化。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。填写的内容必须在一行中完成,否则评分将产生错误。 //proj3.cpp #include <iostream> using namespace std; class Person char * idcardno; //用动态空间存储的身份证号 char * name; //用动态空间存储的姓名 bool ismale; //性别:true为男,false为女 public: Person (const char * pid,const char*pname,bool pmale); ~Person () //**1** **********found********** ______; const char * getIDCardNO () const return idcardno; const char * getName () const return name; void rename (const char * new name); bool isMale () constreturn ismale; ; class Staff:public Person char * department; double salary; public: Staff(const char * id_card_no,const char * p_name,bool is_male,const char * dept,double sal); ~Staff () delete [] department; const char * getDepartment () const return department; void setDepartment (const char * d); double getSalary () const returnsalary; void setSalary(double s) salary=s;; Person::Person(const char * id_card_no, const char * p_name, bool is_male):ismale(is_male) idcardno=new char[strlen(id_card_no)+1]; strcpy(idcardno,id_card_no); name=new char[strlen (p_name)+1]; strcpy(name,p_name); void Person : :rename (const char * new_name) delete []name; //**2** **********found********** ______; strcpy(name,new_name); Staff::Staff (const char * id_card_no, const char * p_name, bool is_male, //**3** **********found********** const char * dept,double sal):______ department=new char[strlen(dept)+1]; strcpy(department,dept); salary=sal; void Staff::setDepartment(const char*dept) delete [] department; department=new char[strlen(dept)+1]; strcpy(department,dept); int main() Staff Zhangsan ("123456789012345","张三",false,"人事部",1234.56); Zhangsan.rename("张小丽"); cout<<Zhangsan.getName()<<Zhangsan.getIDCardNO()<<endl; return 0;
进入题库练习
问答题使用VC++6.0打开 下的源程序文件2.cpp。阅读下列函数说明和代码。函数num(char *str)用于返回字符串中非数字的个数。 例如:abc123abc45 返回值为:6 将函数num补充完整。 注意:请勿改动主函数main。 试题程序: #include<iostream.h> int num(char *str) { } int main() { char str[1024]; cout<<"please input a string:"<<endl; cin.getline(str,1024); cout<<"char number is"<<num(str)<<endl; return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,此工程中含有—个源程序文件proj1.cpp。其中位于WI"注释“//ERROR**********found**********”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:NUM=0Value=1注意:只修改注释“//ERROR****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>usingnamespacestd;classMyClass{inti;friendvoidIncrement(MyClass&f);public:constintNUM;//ERROR********found********MyClass(inti=0){NUM=0;_i=i;}intGetValue()const{returni;)};//ERROR********found********voidIncrement(){f.i++;}intmain(){MyClassobj;//ERROR********found********MyClass::Increment(obj),cout<<"NUM="<<obj.NUM<<end1<<"Value="<<obj.GetValue()<<end1;return0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,其中有矩形类Rectangle、函数show和主函数main的定义。程序中位于每个“//ERROR ****found****”下一行的语句有错误,请加以改正。改正后程序的输出结果应该是: Upper left=(1,8),down right=(5,2),area=24. 注意:只修改每个“//ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> #include <cmath> using namespace std; class Rectangle{ double x1, y1; //左上角坐标 double x2, y2; //右下角坐标 public: // ERROR ********** found********** Rectangle (double x1, y1; double x2, y2){ this ->x1=x1; this ->y1=y1; this ->x2=x2; this ->y2=y2; } double getX1 ()const{ return x1; } double getY1 ()const{ return y1; } double getX2 ()const{ return x2; } double getY2 ()const{ return y2; } double getHeight () const { return fabs(y1-y2);} double getWidth () const { return fabs(x1-x2);} double area () const { return getH-eight()* getWidth(); } }; // ERROR ********** found********** void show(Rectangle r)const{ cout <<"Upper left = ("; // ERROR ********** found********** cout << r.x1 <<", " << r.y1 <<"), down right = (" <<r.x2 <<", " <<r.y2; cout << "), area =" << r. area () << ". " << endl; } int main(){ Rectangle r1 (1, 8, 5, 2); show(r1); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹prog3下的工程prog3,其中包含了类Polynomial(“多项式”)的定义。 形如5x4+3.4x2-7x+2的代数式称为多项式,其中的5为4次项系数,3.4为2次项系数,-7为1次项系数,2为0次项(常数项)系数。此例缺3次项,意味着3次项系数为0,即省略了0x3。在Polynomial中,多项式的各个系数存储在一个名为coef的数组中。例如,对于上面的多项式,保存在coef[0]、coef[1]…coef[4]中的系数依次为:2.0、-7.0、3.4、0.0、5.0,也即对于i次项,其系数就保存在coef[i]中。成员函数getValue计算多项式的值,多项式中x的值是由参数指定的。 请补充完成文件Polynomial.cpp中成员函数getValue的定义。此程序的正确输出结果应为: Value of p1 when x=2.0:59.8 Value of p2 when x=3.0:226.8 注意:只在函数getValue的“//********333********”和“//********666********”之间填入若干语句,不要改动程序中的其他内容。 //Polynomiac.h #include <iostream> using namespace std; class Polynomial{ //"多项式"类 public: Polynomial (double coef [], intnum): coef (new double [num] ), num_of_terms (num){ for(int i=0; i<num_of_terms; i++) this->coef[i] =coef[i]; } ~Polynomial() { delete[] coef;} //返回指定次数项的系数 double getCoefficient (int power)const{ return coef[power]; } //返回在x等于指定值时多项式的值 double getValue (double x) const ; private : //系数数组, coef[0]为0次项(常数项)系数,coef[1]为1次项系数, coef[2]为2次项(平方项)系数, 余类推。 double * coef; int num of terms; }; void writeToFile(const char * path); //Polymomial.cpp #include"Polynomial.h" double Polynomial::getValue (double x)const{ //多项式的值value为各次项的累加和 double value = coef[0]; //********333******** //********666******** return value; } //main.cpp #include "Polynomial.h" int main() { double p1[] = {5.0, 3.4, -4.0, 8.0}, p2[] ={0.0, -5.4, 0.0, 3.0, 2.0}; Polynomial poly1 (p1, sizeof (p1)/sizeof (double)), poly2 (p2, sizeof(p2)/sizeof (double)); cout <<"Value of p1 when x =2.0 : "<<poly1.getValue (2.0) <<endl; cout <<"Value of p2 when x =3.0 : "<<poly2.getValue (3.0) <<endl; writeToFile (" "); return 0; }
进入题库练习
问答题请使用菜单命令或直接用VC6打开 下的工程prj03。请完善下列程序,实现一个Number类。Add函数计算2个Number类对象之和,并将和作为Number对象返回。这2个Number对象中各包含一个用字符串表示的10进制正整数,均不超过int的表示范围。在main函数中给出了一组测试数据,使用这组数据进行测试时程序的输出应该是: 100 注意:只需在//********333********和//********666********之间填入所编写的若干语句,不要改动程序中的其他内容。 #include<iostream> #include<cstring> #include<sstream> #include "proj3.h" using namespace std; Number::Number(char*n){ num=new char[strlen(n)+1]; strcpy(num, n); } Number::Number(Number strcpy(num, n.num); } Number::Number(int n){ char*tmp=new char[30]; itoa(n, tmp, 10); //函数itoa的功能是将n转换为字符串,存放于tmp指向的数组中 num=new char[strlen(tmp)+1]; strcpy(num, tmp); } Number::~Number(){ if(num) delete[]num; } Number Number::Add(Number n){ //*******333******* //*******666******* } nt main(){ Number num1("32"); Number num2("68"); Number cout<<num3.GetNum(); writeToFile("c:/test"); return 0; } //proj3/proj3.h class Number{ private: char*num; //具体数字,num[0]表示最高位的数 public: ~Number(); Number(char*n); Number(Number Number(int n); Number Add(Number n); char*GetNum(){return num;} }; void writeToFile(const char*path);
进入题库练习
问答题使用VC6打开 proj1下的工程proj1,其中有“沙发”类Sofa和主函数main的定义。程序中位于每个//ERROR**********found**********下的语句行有错误,请加以更正。更正后程序的输出应该是: 座位数:3 颜色:红色 注意:只能修改每个//ERROR**********found**********下的那一行,不要改动程序中的其他内容。 #include<iostream> using namespace std; class Sofa{ //“沙发”类 int seats; //座位数 char color[10]; //颜色 public: //ERROR******found****** Sofa(int s,const char*co) { //ERROR******found****** if(co=NULL) color[0]="/0"; else strcpy(color,co); } //ERROR******found****** const char*getSeats()const{return seats;} const char*getColor()const{return color;} }; int main(){ Sofa safa(3); cout<<"座位数:"<<sara.getSeats()<<endl; cout<<"颜色:"<<sara.getColor()<<endl; return 0; }
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,该程序运行时有错误,请改正其中的错误,使程序正确运行。并且使程序输出的结果为: OK 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> class CBase { public: CBase() { a=b=0; } private: int a,b; }; class CDerive1: public CBase { public: CDerive1() { } //******error****** virtual void func(); }; class CDerive2: public CDerive1 { public: CDerive2() { a=0; b=0; } void func() { //******error****** cout "OK"<endl; } private: int a; int b; }; void main() { CDerive2 obj; //******error****** CDerive1 *p=(CDerive1*) obj; p->func(); }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj2下的工程proj2,此工程中包含一个头文件shape.h,其中包含了类Shape、Point和Triangle的声明;包含程序文件shape.cpp,其中包含了类Triangle的成员函数和其他函数的定义;还包含程序文件proj2.cpp,其中包含测试类Shape、Point和Triangle的程序语句。请在程序中的横线处填写适当的代码并删除横线,以实现上述功能。此程序的正确输出结果应为: 此图形是一个抽象图形,周长=0,面积=0 此图形是一个三角形,周长=6.82843,面积=2 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“// ****found****”。 //shape.h class Shape { public: virtual double perimeter() const {return 0;} //返回形状的周长 virtual double area() const {return 0;} //返回形状的面积 virtual const char * name() const {return "抽象图形";} //返回形状的名称 }; class Point{ //表示平面坐标系中点的类 double x; double y; public: // **********found********** Point (double x0, double y0): ______{} //用x0、y0初始化数据成员x、y double getX() const {return x;} double getY() const {return y;} }; class Triangle: public Shape{ // **********found********** ______; //定义3个私有数据成员 public: Triangle (Point p1, Point p2, Point p3): point1 (p1), point2 (p2), point3 (p3) {} double perimeter () const; double area() const; const char * name() const {return "三角形";} }; //shape.cpp #include "shape.h" #include <cmath> double length (Point p1, Point p2) { return sqrt ((p1.getX() -p2.getX()) * (p1.getX() -p2.getX()) + (p1.getY() -p2.getY()) * (p1.getY() -p2.getY())); } double Triangle:: perimeter () const {//一个return语句,它利用length函数计算并返回三角形的周长 // **********found********** ______; } double Triangle::area() const { double s = perimeter()/2.0; return sqrt (s * (s - length (point1, point2)) * (s - length (point2, point3)) * (s - length (point3, point1))); } //proj2.cpp #include "shape.h" #include <iostream> using namespace std; // **********found********** ______ //show函数的函数头(函数体以前的部分) { cout << "此图形是一个" << shape.name() << ",周长=" << shape.perimeter() << ",面积=" << shape.area() << endl; } int main() { Shape s; Triangle tri(Point(0,2), Point(2,0), Point(0,0)); show(s); show(tri); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: smaller smaller smaller largest 注意:只修改注释“//ERROR ********found********”的下一行语句,不要改动程序中的其他内容。 //proj1.cpp #include <iostream> using namespace std; const int Size =4; class MyClass { public: MyClass(int x=0) :value(x) { } void Set(int x) { value=x; } friend void Judge(MyClass private: int value; }; // ERROR ********** found********** voidMyClass::Judge(MyClass else cout <<"smaller" << endl; } int main () { MyClass * ptr =new MyClass[Size]; for(int i=0;i
进入题库练习
问答题基本操作 请使用"答题"菜单或使用VC6打开考生文件夹proj1下的工程proj1,其中有"住宅"类Home 和主函数main的定义。程序中位于每个// ERROR **********found**********下的语句行有错误,请加以更正。更正后程序的输出应该是: 南21条12号 李四 注意:只能修改每个// ERROR **********found**********下的那一行,不要改动程序中的其他内容。
进入题库练习
问答题使用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:”<
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成类MyArrayClass的构造函数,申请数组的大小,请在注释//********1********后添加适当的语句。 (2)完成类MyArrayClass的析构函数,释放数组,请在注释//********2********后添加适当的语句。 (3)完成重载运算符“[],用来获得指定下标的数据,请在注释//********3********后添加适当的语句。 (4)完成函数SetElement(),用来设置指定下标的数据。如果数据没有超出范围,则设置数据,并返回1,否则返回0,请在注释//********4********后添加适当的语句。 注意:除在指定的位置添加语句外,并不要更改程序中的其他语句。 #include<iostream.h> template<class T> class MyArrayClass { private: T* data; int length; public: MyArrayClass (int len) { length=len; //********1******** } ~MyArrayClass() { //********2******** } 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; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹pmj1下的工程proj1。此工程中包含源程序文件main.cpp,其中有类TVSet(“电视机”)和主函数main的定义。程序中位于每个“//ERROR**********found**********”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是:规格:29英寸,电源:开,频道:5,音量:18规格:29英寸,电源:关,频道:一1,音量:一1注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>usingnamespacestd;classTVSet{//“电视机”类constintsize;intchannel;//频道intvolume;//音量boolon;//电源开关:true表示开,false表示关public:TVSet(intsize):size(size),channel(0),on(false)//ERROR*********found*********{}intgetSize()const{returnSize;}//返回电视机规格boolisOn()const{returnon;)//返回电源开关状态//返回当前音量,关机情况下返回一1intgetVolume、()const{returnisOn()?volume:一1;)//返回当前频道,关机情况下返回一1intgetChannel()const{returnisOn()?channel:一1;)voidturnOnOff(){on=!on;}//将电源在“开”和“关”之间转换voidsetChannelTo(intchan){//设置频道(关机情况下无效)if(isOn()&&chan>:0&&chan<=99)//ERROR*********found*********;}//ERROR*********found*********voidsetVolumeTo(intvol)const{//设置音量(关机情况下无效)if(isOn()&&vol>=0&&vol<=20)volume=vol;}VOidshowstate(){cout<<规格:"<<getSize()<<"英寸"<<",电源:"<<(isOn()?"开":"关")<<",频道:"<<getChannel()<<",音量:"<<getVolume()<<end1; }};intmain(){TVSettv(29);tv.turnOnOff();tv.setChannelTo(5);tv.showstate();tv.turnOnOff();tv.showstate();return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义私有常量PI, 请在注释∥********1********后添加适当的语句。 (2)完成类的私有常量PI的赋值,以及完成对半径radius的赋值。请在注释∥********2********后添加适当的语句。 (3)完成计算圆面积的函数GetArea0。请在注释∥********3********后添加适当的语句。 (4)完成计算圆周长的函数GetGirth0。请在注释∥********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include #define CONST PI 3.141592 Class 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 msin() { CCircle circle(5); cout<
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为:Name:SmithAge:21ID:99999CourseNum:12Record:970注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>usingnamespacestd;clasSStudentInfo{protected://ERROR**********found**********CharName;intAge;intID;intCourseNum;floatRecord;public:StudentInfo(char*name,intAge,intID,intcourseNum,floatrecord);//ERROR**********found**********void~StudentInfo(){}floatAverageRecord(){returnRecord/CourseNum;}voidshow()const{cout<<"Name:¨<<Name<<"Age:"<<Age<<"ID:"<<ID<<"CourseNum:"<<CourseNum<<”Record:"<<Record<<end1; }};//ERROR**********found**********StudentInfoStudentInfo(char*Name,intAge,intID,intCourseNumlfloatRecord){Name=name;Age=age;thiS->ID=ID;CourseNum=courseNum;Record=record;}intmain(){StudentInfost(”Smith”,21,99999,12,970);st.show();return0;}
进入题库练习
问答题使用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: "<
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并且使程序输出的结果为: a=7,b=0 a=8,b=10 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> class CObj { public: //******error****** friend void func(CObj void display() { //******error****** cout "a=" a<", b=" b endl; } private: int a,b; }; void func(CObj obj.b=0; } void func (CObj obj.b=j; } void main() { //******error****** CObj obj1 func(obj1,7); obj1.display(); func(obj1,8,10); obj1.display(); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使该程序的输出结果为: 100 注意:错误的语句在//*****error******的下面,修改该语句即可。#include<iostream.h>static int x=50;int t=0;int *func(int x,int y,int z){ t=t+x+y+z; //*****error****** return t;};void main(){ int y=30; int x=10; int z=20; //*****error****** x=x; //*****error****** cout<<func(x,y,z)<<end1;}
进入题库练习