计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题请使用VC6或使用【答题】菜单打开考生文件夹proi2下的工程proj2,其中定义了Employee类和Manager类。Employee用于表示某公司的雇员,其属性包括姓名(nfllIle)和工作部分(dept)。Nanager是Employee的公有派生类,用于表示雇员中的经理。除了姓名和工作部分之外,Nanager的属性还包括级别(level)。Employee类的成员函数print用于输出雇员的信息;Nanager类的成员函数print负责输出经理的信息。请在横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为: Name:Sally Smith Dept:Sales Leve1:2 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iostream>#include<string>using namespace std;clas s Employee{public: Employee (string name, string dept)://********** found********** { } virtual void print()const; string dept()const//返回部门名称 {//**********found********** } virtual—Employee(){)private:string name_; string dept_; }; class Manager:public Employee{ public: Manager(string name,string dept,int level)://**********found********** { } virtual void print()const; private: int level; }; void Employee::print()const { cout<<”Name:”<<name <<endl; cout<<”Dept:”<<dept一<<endl; } VOid Manager::print()const { //**********found********** cout <<”Level:” <<level <<endl;}int main(){ Employee*emp=new Manager(”Sally Smith”,”Sales”,2); emp一>print(); delete emp;return 0;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数DecToBin(char *des,int n)的功能是将十进制数据n转换成二进制数据,并将转换结果存放在des中。 如:120的二进制数据为1111000 例: DecToBin(char *des,120); cout des endl; 输出为:1111000 注意:不能修改程序的其他部分,只能补充DecToBin(char*des,int n)函数。 #include <iostream.h> #define MAXLEN 1024 void DecToBin(char *des,int n) { } void main () { char des[MAXLEN]; int n=120; DecToBin(des,n); cout des endl; return; }
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请补充完整程序fun(int i),使其完成以下功能:如果i=5,则输出如下5行井号。 # ## ### #### ##### 注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。 试题程序: #include<iostream.h> void fun(int i) int main() fun(5); return 0;
进入题库练习
问答题改错题 使用VC6打开考生文件夹下的工程test19_1,此工程包含一个源程序文件test19_1.cpp,但该程序运行有问题,请改正程序中的错误,使程序的输出结果如下: 1: weight:5 age:0 2: weight:7 age:9 源程序文件test19_1.cpp清单如下: #include class animal { public: /**************** found *******************/ friend void setvalue(animal /**************** found *******************/ viod print(); protected: int itsweight; int itsage; }; void animal::print() { cout<<"weight:"<
进入题库练习
问答题请使用VC6或使用[答题]菜单打开 proj2下的工程proj2,其中有矩阵基类MatrixBase、矩阵类Matrix和单位阵UnitMatrix的定义,还有main函数的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应为: 1 2 3 4 5 2 3 4 5 6 3 4 5 6 7 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include<iostream> using namespace std; //矩阵基础类,一个抽象类 class MatrixBase { int rows, cols; public: MatrixBase(int rows, int cols): rows(rows), cols(cols) {} int getRows()const {return rows;}//矩阵行数 int getCols()const {return cols;}//矩阵列数 virtual double getElement(int r, int c)const=0;//取第i个元素的值 void show()const {//分行显示矩阵中所有元素 for(int i=0; i<rows; i++) { cout<<endl; for(int i=0; j<cols; j++) //**********found********** cout<<______<<" "; } } }; //矩阵类 class Matrix: public MatrixBase { double*val; public: //**********found********** Matrix(int rows, int cols, double m[]=NULL):______ { //**********found********** val=______; for(int i=0; i<rows*cols; i++) val[i]=(m==NULL?0.0: m[i]); } ~Matrix() {delete[]val;} double getElement(int r. int c)const {return val[r*getCols()+c];} }; //单位阵(主对角线元素都是1,其余元素都是0的方阵)类 class UnitMatrix: public MatrixBase { public: UnitMatrix(int rows): MatrixBase(rows, rows) {} //单位阵行数列数相同 double getElement(int r, int c)const { //**********found********** if(______)return 1.0; return 0.0; } }; int main() { MatrixBase*m; double d[][5]= {{1, 2, 3, 4, 5}, {2, 3, 4, 5, 6}, {3, 4, 5, 6, 7}}; m=new Matrix(3, 5,(double*)d); m->show(); delete m; cout<<endl; m=new UnitMatrix(6); m->show(); delete m; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为: TestClass1 TestClass2 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>#include<assert.h>struCt TestClass0{ //********error******** virtual void fun();};class TestClassl:publicTestClass0{ void fun() { cout<<"TestClass1"<<endl; }};class TestClass2:publicTestClass0{ Void fun() ( cout<<"TestClass2"<<endl; }};Void main(){ TestClass0*p; TestClass1 obj1; TestClass2 obj2; //********error******** P=*obj1; P->fun(); //********error******** p=*obj 2; p->fun(); return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi.cpp,该程序运行时有错误,请改正错误,使得程序正常运行,并且要求最后一个catch()必须抛出执行的任何异常。 程序通过抛出异常输出: error 0 ERROR 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>int main(){ try { throw("error"); } //********error******** catch(char s) { cout<<s<<endl; } try { throw((int)0); } //********error******** catch() { cout<<i<<endl; } try { throw(0); throw("error"); } //********error******** catch() { cout<<"ERROR"<<endl; } return 0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中声明了MiniComplex是一个用于表示复数的类。请编写这个operator+运算符函数,以实现复数的求和运算。两个复数的和是指这样一个复数:其实部等于两个复数的实部之和,其虚部等于两个复数的虚部之和。例如,(23+34i)+(56+35i)等于(79+69i)。 要求: 补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //Minicomplex.h #include <iostream> using namespace std; class MiniComplex //复数类 { public: //重载流插入和提取运算符 friend ostream return osObject; } friend istream isObject >> complex.realPart >>ch >> complex.imagPart >> ch; return isObject; } MiniComplex(double real = 0, double imag = 0); //构造函数 MiniComplex operator + ( constMiniComplex //重载运算符+ private: double realPart; //存储实部变量 double imagPart; //存储虚部变量 }; voidwriteToFile(char * ); //main.cpp #include "MiniComplex.h" MiniComplex::MiniComplex(double real, double imag) { realPart = real; imagPart = imag;} MiniComplex MiniComplex:: operator + (constMiniComplex MiniComplex numl (23, 34), num2 (56, 35); cout <<"Initial Value of Num1 = "<<numl <<"/nInitial Value of Num2 =" << num2 << endl; cout <<num1 <<" + " <<num2 <<" = "<<num1 + num2 <<endl; //使用重载的加号运算符 writeToFile (""); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中包含了类IntegerSet和主函数main的定义。一个IntegerSet对象就是一个整数的集合,其中包含0个或多个无重复的整数;为了便于进行集合操作,这些整数按升序存放在成员数组elem的前若干单元中。成员函数add的作用是将一个元素添加到集合中(如果集合中不存在该元素),成员函数remove从集合中删除指定的元素(如果集合中存在该元素)。请编写成员函数remove。在main函数中给出了一组测试数据,此时程序的正确输出结果应为: 2 3 4 5 27 28 31 66 75 2 3 4 5 6 27 28 31 66 75 2 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 要求: 补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数WriteToFile已经编译为obj文件,并且在本程序中调用。//IntegorSet,h#i fndef INTEGERSET#de fine INTEGERSET#inClude<iostream>using namespace std;const int MAXELEMENTS=100;//集合最多可拥有的元素个数class IntegerSet{ int elem[MAXELEMENTS]; //用于存放集合元素的数组 int counter;//用于记录集合中元素个数的计数器public: IntegerSet():counter(0)(} //创建一个空集合 IntegerSet(int data[],int size); //利用数组提供的数据创建一个整数集合 void add(int element); //添加一个元素到集合中 void remove(int element); //删除集合中指定的元素 int getCount()const{return counter;) //返回集合中元素的个数 int getElement(int i)const{return elem[i];)//返回集合中指定的元素 void show()const; }; void WriteToFile(char*); #endif //main.cpp #include”IntegerSet.h” #include<iomanip> IntegerSet::IntegerSet(int data[], int Size):counter(0){ for(int i=0;i<Size;i++) add(data[i]); } void IntegerSet::add(int element){ int j; //从后往前寻找第一个小于等于element的元素 for(j=counter;j>0;j一一) if(element>=elem[j—1])break; //如果找到的是等于element的元素,说明要添加的元素已经存在,直接返回 if(j>0) if(element==elem[j一1])return; //如果找到的是小于element的元素,j就是要添加的位置 //该元素及其后面的元素依次后移,腾出插入位置 for(int k=counter;k>j;k一一) elem[k]=elem[k—1]; elem[j]=element;//将element插入到该位置 counter++; //计数器加1 } void IntegerSet::remove(int ele。 ment){ //********333******** //********666******** } void IntegerSet::show()const{ for(int i=0;i<getCount();i++) cout<<setw(4)<<getElement(i); cout<<endl; } int main(){ int d[]={5,28,2,4,5,3,2,75,27,66,31}; IntegerSet S(d,11); s.show(); S.add(6); S.show(); S.add(19); S.show(); S.remove(2); S.show(); S.add(4); S.show(); WriteToFile(””); return 0; }
进入题库练习
问答题用VC++6.0打开考生文件夹下的源程序文件3.cpp,这个工程完成输出到屏幕一些特定的信息,但工程有错误或者不完整,请完成以下功能:   (1)初始化Num2的值为j,请在注释1后添加适当的语句。   (2)补充全局函数fun使之能够调用类TC的成员变量,请在注释2后添加适当的语句。   (3)初始化静态变量,请在注释3后添加适当的语句。   (4)修改注释4后的语句。使得程序输出以下内容:   Num1=7   Num2=12   Num3=-7   Num1=6   Num2=9   Num3=-17   注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。   试题程序:   #include   classTC   {   public:   //********1********   TC(inti,intj)   {   Num1=i:   Num3-=i:   }   voidPrint()   {   cout<<"Numl="<  cout<<"Num2="<  cout<<"Num3="<  }   voidAdd(inti)   {   Num3-=i:   }   private:   intNuml;   constintNum2;   staticintNum3;   //********2********};   //********3********voidfun(  )   {   TCobj(5,9);   obj.Numl=6;   //********4********obj.Add(  );   obj.Print(  );   }   voidmain(  )   {   TCobj(7,12);   obj.Print(  );   fun(  );   return;   }
进入题库练习
问答题请使用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 ) : roomno (the_room_no) , length ( the_length) , width ( the_width ) int theRoomNo() const return roomno ; //返回房间号 double theLength()const return length; //返回房间长度 double theWidth()const return width; //返回房间宽度 //********** found ********** double theArea () const ______ //返回房间面积(矩形面积) ; class Office: public Room //"办公室"类 char * depart; //所属部门 public : Office(int the_room_no, double the_length, double the_width, const char * the_depart) //********** found ********** :______ depart = new char[ strlen(the_depart) + 1 ] ; //********** found ********** strcpy (______) ; ~Office() delete []depart; const char * theDepartment() const return depart; //返回所属部门 ; int main() //********** found ********** Office ______; cout << "办公室房间号:" << an_office. theRoomNo() << endl << "办公室长度:" << an_office. theLength() << endl << "办公室宽度:" << an_office. theWidth() << endl << "办公室面积:" << an_office. theArea() << endl << "办公室所属部门" << an_office. theDepartment() << endl; return 0 ;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中包含主程序文件main.cpp和用户定义的头文件Array.h,整个程序包含有类Array的定义和主函数main的定义。请把主程序文件中的Array类的成员函数Contrary()的定义补充完整,经补充后运行程序,得到的输出结果应该是: 5 8 5,4,3,2,1 0,0,8.4,5.6,4.5,3.4,2.3,1.2注意:只允许在“//**********333**********”和“//**********666**********”之间填写内容,不允许修改其他任何地方的内容。//Array.h#include<iostream>using namespace std;template<class Type,int m>class Array{//数组类public: Array(Type b[],int mm){ //构造函数 for(int i=0;i<m;i++) if(i<mm)a[i]=b[i];else a[i]=0; } void Contrary();//交换数组a中前后位置对称的元素的值 int Length()const{return m;)//返回数组长度 Type operator[](int i)const{//下标运算符重载为成员函数 if(i<0 || i>=m){cout<<"下标越界!"<<endl;exit(1);) return a[i],. }private: Type a[m]; }, void writeToFile(const char*); //不用考虑此语句的作用 //main.cpp #include”Array.h” //交换数组a中前后位置对称的元素的值 template<class Type,int m> void Array<Type,m>::Contrary(){ //补充函数体 //********333******** //********666******** } int main(){ int sl[5]={1,2,3,4,5}; double s2[6]={1.2,2.3,3.4,4.5,5.6,8.4); Array<int,5>dl(s1,5); Array<double,8>d2(s2,6); int i; d1.Contrary(); d2.Contrary(); cout<<d1.Length()<<"<<d2.Length()<<end1; for(i=0;i<4;i++) cout<<d1[i]<<”,”; cout<<d1[4]<<end1; for(i=0;i<7;i++) cout<<d2[i]<<”,”; cout<<d2[7]<<end1; writeToFile(””);//不用考虑此语句的作用 return 0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程prog3,其中声明了ValArmy类,该类在内部维护一个动态分配的整型数组。ValArray类的复制构造函数应实现对象的深层复制。请编写ValArray类的复制构造函数。在main函数中给出了一组测试数据,此种情况下程序的输出应该是:ValArrayvl={1,2,3,4,5}ValArrayv2={2,2,2,2,2}要求:补充编制的内容写在“//********333********”与“//********666********”之间。不要修改程序的其他部分。注意:相关文件包括:mmn.cpp、ValArray.h。程序最后调用writeToFile函数,使用另一组不同的测试数据,将不同的运行结果输出到文件out.dat中。输出函数writeToFile已经编译为obi文件。//ValArray.h#include<iostream>usingnamespacestd;classValArray{int*v;intsize;public:ValArray(constint*P,intn):size(n){v=newint[size];for(inti=0;i<size;i++)v[i]=P[i];}ValArray(constValArray&other);~ValArray(){delete[]V;lvoidsetElement(inti,intval){v[i]=val;}voidprint(ostream&out)const{out<<'{';for(inti=0;i<size-1;i++)out<<v[i]<<",";out<<v[size-1]<<')';}};voidwriteToFile(constchar*);//main.cpp#include"ValArray.h"ValArray::ValArray(constValArray&other){//********333********//********666********}intmain(){constinta[]={1,2,3,4,5);ValArrayvl(a,5);ValArrayv2(v1);for(inti=0;i<5;i++)v2.setElement(i,2);cout<<”ValArrayvl=”;v1.print(cout);cout<<end1;cout<<"ValArrayv2=";v2.print(cout);cout<<end1;writeToFile("");return0;}
进入题库练习
问答题使用VC++6.0打开 下的源程序文件3.cpp。其中定义的类不完整,按要求完成下列操作,将类的定义补充完整。 (1)完成类TC1的成员函数seta的定义,定义seta对象,x为int 类型,请在注释1后添加适当的语句。 (2)完成类TC3多继承类TC1和TC2的定义,请在注释2后添加适当的语句。 (3)定义类TC3中的私有成员c为int型,请在注释3后添加适当的语句。 (4)完成setc中对基类的变量a的赋值,请在注释4后添加适当的语句。 注意:增加或者修改代码的位置已经用符号表示出来,请不要修改其他的程序代码。 试题程序: #include<iostream.h> class TC1 { int a; public: //********1******** { return a=x; } void showa() { cout << a << endl; } }; class TC2 { int b; public: void setb(int x) { b=x; } void showb() { cout << b << endl; } }; //********2******** { private: //********3********public: void setc(int x,int y,int z) { c=z; //********4******** setb(y); } void showc() { cout <<c << endl; } }; void main() { TC3 c; c.seta(5); c.showa(); c.setc(5,7,4); c.showc(); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能:(1)定义CMyTime的私有成员函数m year、m month类型为int,请在注释//********1********后添加适当的语句。(2)补充完成CMyTime的构造函数,完成对m year、m month的赋值,请在注释//********2********后添加适当的语句。(3)完成print()的输出,请在注释//********3********后添加适当的语句。输出格式如下:Current Time year:xx month:xx注意:xx表示两位0~9的数字,如Current Time year:08month:04。(4)完成对month的增加函数AddMonth(int m),请在注释//********4********后添加适当的语句。注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>class CMyTime{private://********1********public:CMyTime(int year,int month){//********2********}void display(){char yearChar[3];char monthChar[3];yearChar[0]=(m_year%100)/i0+'0';yearChar[1]=(m_year%10)+'0';monthChar[0]=(m_month%100)/10+'0';monthChar[1]=(m_month%10)+'0';//********3********cout<<"Current Time"<<"year:"<<yearChar<<"month:"<<monthChar<<endl;}void AddMonth(int m){m_month=m_month-1+m;//********4********m_month=m_month%12+1;}void AddYear(int n){m_year=m_year+n;}};int main(){CMyTime myTime(2006,11);myTime.AddMonth(5);myTime.display();myTime.AddYear(1);myTime.display();return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成以下函数: int factorial(int n):求出n的阶乘,必须使用递归调用。 如果n小于1则返回0。 注意:不能修改函数的其他部分。 #include #include int factorial(int n) { } void main() { cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成列操作,将类的定义补充完整,实现以下功能:(1)完成CBook类构造函数,对整型变量ID和作者Author进行赋值,请在注释//********1********后添加适当的语句。(2)完成类CBooks的析构函数,释放申请的内存,请在注释//********2********后添加适当的语句。(3)完成类CBooks的AddBookMember函数,请在注释//********3********后添加适当的语句。(4)完成CBooks类,用于由书的ID检索到作者的函数char*GetBookAuthor(intnID),请在注释//********4********后添加适当的语句。(5)程序的输出结果为:TomHarry注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>#include<cstring>clasS CBook{public:int ID;char Author[32];public:CBook(int ID_Number,char*Author_Name){this->ID=ID_Number;//********1********}};class CBooks{private:class Node{public:Node* next;CBook*book;}*m_pBook;public:CBooks(){m_pBook=NULL;}~CBooks(){//********2********while(){Node*p=m_pBook->next;deletem_pBook->book;delete m_pBook;m_pBook=p;}}int AddBookMenber(intnID,char* Author){Node*P=m_pBook;Node*q=NULL;//********3********while(){if(nID==P->book->ID){return0j;}?q=p;p=p->next;}if(p==NULL){p=newNode;p->next=NULL;p->book=newCBook(nID,Author);}if(q==NULL){m_pBook=p;}else{q->next=p;}return1,}char* GetBookAuthor(int nID){Node*p=m_pBook;//********4********while(){if(Pp->book->ID==nID){return p->book->Author;}p=p->next;}return0;}};int main(){CBooks books1;books1.AddBookMenber(1,"Tom");books1.AddBookMenber(3,"Lee");books1.AddBookMenber(4,"Lily");books1.AddBookMenber(5,"Harry");cout<<books1.GetBookAuthor(1)<<endl;cout<<books1.GetBookAuthor(5)<<endl;return0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程包含一个源程序文件proj2.cpp。其中定义了Score类。 Score是一个用于管理考试成绩的类。其中,数据成员一s指向存储成绩的数组,_n表示成绩的个数;成员函数Sort使用冒泡排序法将全部成绩按升序进行排列。 请在程序中的横线处填写适当的代码,然后删除横线,以实现Score类的成员函数Sort。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。//proj2.cpp#include<iostream>#include<cstdlib>#include<ctime>using namespace std;clasS Score{public: Score(double*S,int n):_S(S),_n(n){} double GetScore(int i)const{return S[i];) void Sort();private: double* S; int n; }; void Score::Sort() { //********found******** for(int i=0;i< n一1; } //********found******** for(int j= ;j>i;j一一) if(_S[j]<_S[j一1]) { //交换_s[j]和_s[j一1] double t=S[j]; //******** found******** ________;: //******* found******** _______; } } int main() { const int NUM=10; double S[NUM]; srand(time(0)); for(int i=0;i<NUM;i++) S[i]=double(rand())/RAND MAX*100; Score SS(S,NUM); SS.Sort(); for(int J=0;j<NUM;j++) cout<<SS.GetScore(j)<<endl; return 0; }
进入题库练习
问答题使用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打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成构造函数,设置数组元素的个数为0,请在注释∥********1********之后添加语句。 (2)完成函数AddMember(int n),如果参数n包含在类的数据成员数组中,则返回0,否则把数据写入数组,然后返回1,请在注释∥********2********之后添加语句。 (3)完成函数DelMember(int n),如果变量在数据中,则删除该变量,并且返回1,如果不存在则返回0,请在注释∥********3********之后添加语句。 (4)完成成员函数isInclude(int n)的定义,该函数检查参数n是否在类的数据成员数组elems中,如果在返回1,否则返回0。请在注释∥********4********之后添加语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iOStream.h>#define MAX LENGTH 500clas s CArray{public: CArray() { ∥********1******** } int AddMember(int n) { for(int i=0;i<length;i++) { ∥********2******** if(Array[i]=n) return 0; } Array[length++]=n; return 1; } int DeiMember(int n) { int i; for(i=0;i<length;i++) { if(Array[i]==n) { break; } } ∥********3******** if() { for(;i<length一1;i++) { Array[i]=Array[i+1]; } length一一; return 1; } return 0; } int isInclude(int n) { for(int i=0;i<length;i++) { ∥********4******** if() { return 1; } } return 0; }private: int Array[MAX LENGTH]; int length;//用来记录数组的个数};int main(){ CArray obj; obj.AddMember(1); obj.AddMember(3); obj.AddMember(8); obj.AddMember(23); cout<<obj.iSInclude(8)<<endl; cout<<obj.iSInclude(1 1)<<endl; obj.DeIMember(3); obj.DeiMember(8); cout<<obj.iSInclude(2)<<end1; cout<<obj.iSInclude(1)<<end1; return 0;}
进入题库练习