计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,函数void Insert(node*q)使程序能完成如下功能:从键盘输入一行字符,调用该函数建立反序单链表,再输出整个链表。 注意:请勿修改主函数main和其他函数中的任何内容,只需在横线处编写适当代码,也不要删除或移动“//****found****”。 //proj2.cpp #include <iostream> using namespace std; struct node { char data; node * link; } * head; //链表首指针 void Insert (node * q) //将节点插入链表首部 { //******** found******** ______; head = q; } int main ( ) { char ch; node * p; head = NULL; cout <<"Please input the string" <<endl; while((ch=cin.get()) !='/n') { //******** found******** ______; //用new为节点p动态分配存储空间 p ->data = ch; //******** found******** ______; //插入该节点 } p=head; while (p!=NULL) { cout <<p -> data; p=p->link; } cout << endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义类的私有变量a、b,请在注释∥********1********后添加适当的语句。 (2)完成类的构造函数,对变量a、b赋值,缺省两个变量值为1,在注释∥********2********之后添加语句。 (3)完成打印函数displayO,打印出“a*b=c”格式的一个乘法算式,在注释∥********3********之后添加语句。 (4)补充主函数,使得打印9X9的乘法口诀。在注释∥********4********后添加语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include 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<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 100 37 32 注意:错误的语句在//******error******的下面,修改该语句即可。#include<iostream.h>//******error******void main({ //******error****** int m=0142; //******error****** int n=0X27; int q=32; cout<<m<<endl; cout<<n<<endl; cout<<q<<endl; return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。sum(hatn)计算所有n的因子之和(不包括1和自身)。 注意:不能修改程序的其他部分,只能补充sum()函数。 #include int sum(int n) { } void main() { cout<
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个程序文件main.cpp,其中有日期类Date、人员类Person及排序函数sortByName和主函数main的定义。请在程序中的横线处填写适当的代码并删除横线,以实现上述类定义和函数定义。此程序的正确输出结果应为:按姓名排序排序前张三男出生日期:1978年4月20日王五女出生日期:1965年8月3日杨六女出生日期:1965年9月5日李四男出生日期:1973年5月30日排序后:李四男出生日期:1973年5月30日王五女出生日期:1965年8月3日杨六女出生日期:1965年9月5日张三男出生日期:1978年4月20日注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iOStream>usingnamespacestd;classDate{//日期类intyear,month,day;//年、月、日public:Date(intyear,intmonth,intday):year(year),month(month),day(day){}intgetYear()const{returnyear;}intgetMonth()const{returnmonth;}intgetDay()const{returnday;}};classPerson{//人员类charname[14];//姓名boolismale;//性别,为true时表示男性Datebirthdate;//出生日期public:Person(char*name,booliSmale,Datebirth_date)//**********found**********:________{strcpy(this->name,name);}constchar*getName()const{returnname;}boolisMale()const{returnismale;}DategetBirthdate()const{returnbirthdate;}//利用strcmp()函数比较姓名,返回一个正数、0或负数,分别表示大于、等于、小于intcompareName(constPerson&p)const{//**********found**********________}voidshow(){cout<<end1;cout<<name<<"<<(ismale?"男":"女")<<¨<<"出生日期:"<<birthdate.getYear()<<"年"//显示出生年//**********found**********________//显示出生月<<birth_date.getDay()<<"日";//显示出生日}};voidsortByName(Personps[],intSize){//将人员数组按姓名排列为升序for(inti=0;i<size-1;i++){//采用选择排序算法intm=i;for(intj=i+1;j<size;j++)if(ps[j].compareName(ps[m])<0)m=j;if(m>i){PersonP=ps[m];ps[m]=ps[i];ps[i]=p;}}}intmain(){Personstaff[]={Person("张三",true,Date(1978,4,20)),Person("王五",false,Date(1965,8,3)),Person("杨六",false,Date(1965,9,5)),Person("李四",true,Date(1973,5,30))};constintsize=sizeof(staff)/Si—zeof(staff[0]);inti;cout<<end1<<"按姓名排序";cout<<end1<<"排序前:";for(i:0;i<size;i++)staff[i].show();sortByName(staff,size);cout<<end1<<end1<<"排序后:";for(i=0ji<size;i++)staff[i].show();cout<<end1;return0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,其中包含抽象类Shape的声明,以及在此基础上派生出的类Rectangle和Circle的声明,二者都有计算对象面积的函数GetArea()和计算对象周长的函数GetPerim()。程序中位于每个“//****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是:TheareaoftheCircleis78.5TheperimeteroftheCimleis31.4TheareaoftheRectangleis24TheperimeteroftheRectangleis20注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。#include<iostream>usingnamespacestd;classShape{public:Shape(){}~Shape(){}//**********found**********________floatGetArea()=0;//**********found**********________floatGetPerim()=0;};classCircle:publicShape{public:Circle(floatradius):itsRadius(radius){}~Circle(){}floatGetArea(){return3.14*itsRadius*itsRadius;}floatGetPerim(){return6.28*itsRadius,}private:floatitsRadius;};classRectangle:publicShape{public://**********found**********Rectangle(floatlen,floatwidth):________{};~Rectangle(){};virtualfloatGetArea(){returnitsLength*itsWidth;}floatGetPerim(){return2*itsLength+2*itsWidth;}virtualfloatGetLength(){returnitsLength;}virtualfloatGetWidth(){returnitsWidth;}private:floatitsWidth;floatitsLength;};intmain(){//*****'k****found**********sp=newCircle(5);cout<<"TheareaOftheCircleis"<<sp->GetArea()<<end1;cout<<"TheperimeteroftheCircleis"<<sp->GetPerim()<<end1;deletesp;sp=newRectangle(4,6);cout<<"TheareaoftheRectangleis"<<sp->GetArea()<<end1;cout<<"TheperimeteroftheRectangleis"<<sp->GetPerim()<<end1;deletesp;return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为:10注意:错误的语句在//******error******的下面,修改该语句即可。#include<iostream.h>struct struct{union{int a;char c[4];};int b;//******error******}void main(){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<<m.a<<endl<<m.b<<endl;}
进入题库练习
问答题请使用[答题]菜单命令或直接用VC6打开考生文件夹下的工程proj3,其中声明的是一个人员信息类,补充编制程序,使其功能完整。在main函数中给出了一组测试数据,此种情况下程序的输出应该是:Zhang 20 Tsinghua。 注意:只能在函数address_change的“//********333********”和“//********666********”之间填入若干语句,不要改动程序中的其他内容。 程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //proj3.h #include<iostream> #include<string> using namespace std; class Person char name[20]; int age; char* address; public: Person()age=0;address=0; void name_change(char*name); //名字修改函数 void age_change(int_age); //年龄修改函数 void address_change(char* add); //地址修改函数 void info_display(); //人员信息显示 ~Person(); //析构函数 ; void writeToFile (const char*path); proj3.cpp #include <iostream> #include <string> #include"proj 3.h" using namespace std; void Person::name_change(char*_name) strcpy(name,_name); void Person::age_change(int_age) age=_age; void Person::address change(char*_add) if(address!=NULL) delete [] address; void Person::info_display () cout<<name<<'/t' if(address!=NULL) cout<<address<<endl; cout<<endl; Person::~Person() if(address!=NULL) delete[] address; void main() Person p1; p1.name_change("Zhang"); p1.age_change(20); p1.address_change("Tsinghua Uni-versity"); p1.address_change("Tsinghua"); p1.info_display(); writeToFile(" ");
进入题库练习
问答题使用VC6打开下的源程序文件modi2.cpp。请完成函数fun(intx),该函数功能是判定x的所有的约数,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。例如:x=10的约数为1,2,5,10。注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。#include<iostream>#include<fstream>#include<cmath>usingnamespacestd;voidWriteFile(intc){ofstreamout1;out1.open("modi2.txt",ios_base::binary|iosbase::app);out1c"";out1.close();}voidfun(intx){}voidClearFile(){ofstreamout1;out1.open("modi2.txt");out1.close();}intmain(){ClearFile();fun(10);return0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中包含一个程序文件 main.cpp,其中有类CPolygon(“多边形”)、CRectangle(“矩形”)、CTriangle(“三角形”)的定义。请在横线处填写适当的代码并删除横线,以实现上述类定义。该程序的正确输出结果应为: 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include {toutprintarea(); ppoly2->printarea(); retun 0;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程中含有一个源程序文件proj2.epp,其中定义了Array类。在C++程序中访问数组元素时,如果索引值(下标)小于0或者大于元素个数减1,就会产生越界访问错误。Array是一个带有检查越界访问功能的数组类,其成员列表如下:公有成员函数功能GetValue获取指定元素的值SetValue将指定元素设置为指定值GetLength获取元素个数私有成员函数功能IsOutOfRange检查索引是否越界私有数据成员功能_p指向动态分配的整型数组的指针size存放元素个数Array类的构造函数会动态分配一个int类型数组,以存储给定数量的元素。在公有成员函数GetValue和SetValue中,首先调用私有成员函数IsOutOfRange检查用于访问数组元素的索引是否越界,只有当索引值在有效范围内时,才能进行元素访问操作。请在横线处填写适当的代码,然后删除横线,以实现Array类的功能。此程序的正确输出结果应为:1,2,3,4,5,6,7,8,9,10注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。//proj2.cpp#include<iostream>usingnamespacestd;classArray{public:Array(intsize)//构造函数{//********found********下列语句动态分配一个int类型数组_p=________;size=size;}~Array(){delete[]_p;)//析构函数voidSetValue(intindex,intvalue)//设置指定元素的值{if(IsOutOfRange(index)){ceEE<<"Indexoutofrange!"<<end1;reLurn;}//********found********________;}intGetValue(intindex)const//获取指定元素的值{if(IsOutOfRange(index)){cerE<<"Indexoutofrange!"<<end1;return-1;}//********fOUnd********________;}intGetLength()const{return_size;)//获取元素个数private:int*p;intsize;boolIsOutOfRange(intindex)const//检查索引是否越界{//********found********if(index<0||________)returntrue;elsereturnfalse;}};intmain(){Arraya(10);for(inti=0;i<a.GetLength();i++)a.SetValue(i,i+1);for(intj=0;j<a.GetLength()-1;j++)tout<<a.GetValue(j)<<",";cout<<a.GetValue(a.GetLength()-1)<<end1;return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和C代码,完成空出部分的程序,实现函数fun(char*s1,char*s2)将字符串s2连接在字符串s1之后,构成一个首指针为s1的字符串。 注意:不能修改函数的其他部分。 #include #defitie MAXLINE 1000 void fun(char*s1,char*s2) { } void main() { char s1[MAXLINE]; char s2[2 5 6]; cout<<“please input a string:”<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序,使输入某年某月某日,可判断这一天是这一年的第几天。 程序分析:以3月5日为例,应该先把前两个月的天数加起来,然后再加上5天即本年的第几天(特殊情况:闰年输入月份大于3时需考虑多加一天)。 注意:只能补充函数func(int year,int month,int day),请勿改动其他部分的内容。 #inC1ude int func(int year,int month,int day) { } Void main() { cout<
进入题库练习
问答题 使用VC++6.0打开源程序文件3.cpp。其中类TC用于把文件输出到屏幕,然后进行文件的分割。分割的方法如下:第一个文件的大小是文件的前一半,另外一个文件的大小是剩余部分。此程序将in.txt文件中的内容输出到屏幕,并且将文件按照以上方式分割,存于文件out1.txt和out2.txt中。 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)从输入文件中获得一个字符,并判断是否到文件结尾,如果到文件结尾,则退出循环。请在注释1后添加适当的语句。 (2)把获得的输入文件的内容存储到buf中,并且用len记录下文件的长度。请在注释2后添加适当的语句。 (3)将输入文件的后一半内容存储在第二个文件中,请在注释3后添加适当的语句。 (4)使用文件流对象打开输入文件in.txt,请在注释4后添加适当的语句。 注意:增加代码或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 试题程序: #include<iostream.h> #include<fstream.h> #include<stdlib.h> class TC { public: TC(char * fileName) { len=0; fstream infile; infile.open(fileName,ios::in); char ch; //********1******** while() { cout<<ch: //********2******** } infile.dose(); } void split() { fstream outfile1; fstream outfile2; outfile1.open("out1.txt",ios::out); outfile2.open("out2.txt",ios::out); int i=0; for(i=0;i<len/2;i++) { outfile1<<buf[i]; } do { //********3******** } while(i!=len); outfile1.close(); outfile2.close(); } private: int len; char buf[1024]; }; void main() { //********4******** TC obj(); obj.split(); return; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程pmj3,其中声明了一个单向链表类sList。sList的成员函数Prepend的功能是在链表头部加入一个新的元素。请编写成员函数Prepend。在mmn函数中给出了一组测试数据,此时程序的输出应为: B->A-> ### A-> ### A-> ### exiting inner block exiting outer block 注意:只在函数Prepend的“//********333********”和“//********666********”之间填入若干语句,不要改动程序中的其他内容。 //SList.h struct sListItem { char data; sListItem* next; }; class sList { public: sList() : h(0) {} //0表示空链表 ~sList (); void Prepend (char c); //在链表前端加入元素 void Del (); //删除链表首元素 sListItem* First () const { return h; } void Print() const; void Release (); //销毁链表 private: sListItem* h; //链表头 }; void writeToFile (const char* ); //main. cpp #include <iostream> #include "sList.h" using namespace std; sList:: ~sList () { Release (); } void sList::Prepend (char c) { //********333******** //********666******** } void sList::Del () { sListItem* temp = h; h = h -> next; delete temp; } void sList::Print() const { sListItem* temp = h; while (temp != 0) { cout <<temp -> data << " -> "; temp = temp -> next; } cout << "/n###" << endl; } void sList::Release ( { while (h != 0) Del (); } int main ( ) { sList* ptr; { sList obj; obj.Prepend ('A'); obj.Prepend ('B'); obj.Print (); obj.Del(); obj.Print (); ptr = ptr -> Print(); cout << "exiting inner block" << endl; } cout << "exiting outer block" << endl; writeToFile (""); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,其中有点类Point和线段类Line和主函数main的定义,程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出应为: p1=(8, 4)p2=(3, 5) 注意:只修改两个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。 #include<iostream> #include<cmath> using namespace std; class Point{ double x, y; public: Point(double x=0.0, double y=0.0) //ERROR********found******** {x=x; y=y;} double getX()const{return x;} double getY()const {return y;} //ERROR*********found******** void show()const{cout<<'('<<x<<','<<y<<')'} }; class Line{ Point p1, p2; public: Line(Point pt1, Point pt2) //ERROR********found******** { pt1=p1; pt2=p2;} Point getP1()const{return p1;} Point getP2()const{return p2;} }; int main(){ Line line(Point(8, 4), Point(3, 5)); cout<<"p1="; line.getP1().show(); cout<<"p2="; line.getP2().show(); cout<<endl; return 0; }
进入题库练习
问答题用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义了多个类,但类不能达到输出要求,按照定义的输出修改函数,使得输出如下: TestClass3 TestClass2 TestClass1 其中定义的类并不完整,按照要求完成下列操作,将类的定义补充完整。 (1)类TestClass2公共继承于TestClass1,请在注释********1********后添加适当的语句。 (2)print函数为虚函数,请在注释//********2********后添加适当的语句。 (3)修改语句,使得p指定对象obj3,请在注释//********3********后添加适当的语句。 (4)修改语句,利用p调用print()函数,完成输出信息,注释//********4********后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。 #include<iostream> using namespace std; class TestClass1{public: void print(){ tout<<<''TestClass'''<<endl; }}; //********1********class TestClass2{ public: //********2******** void print() { tout<<''TestClass2''<<endl; } };class TestClass3:public TestClass2{ public: void print() { cout<<''TestClass3''<<endl; }};int main(){ TestClass2 obj2; TestClass3 obj3; TestClass1*p; obj2.print(); obj3.print(); //********3******** p=obj3; //********4******** p.print(); return ();}
进入题库练习
问答题使用VC6打开 下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。sum(int n)计算所有n的因子之和(不包括1和自身)。 注意:不能修改程序的其他部分,只能补充sum()函数。 #include <iostream.h> int sum(int n) { } void main () { cout sum (10) endl; cout sum (200) endl; cout sum (400) endl; return; }
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)定义类的公有数据成员函数No、Name[32],其中No是int型的数据,Name[32]为字符型。请在注释//********1********后添加适当的语句。 (2)完成函数set的定义,分别设置No和Name的值,请在注释//********2********后添加适当的语句。 (3)完成函数print(),请在注释//********3********后添加适当的语句,打印的输出如下: No=111 Name=Garfield (4)加缺省构造函数,设置No为0,Name为空,请在注释//********4********后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。 #include<iostream.h> C1ass TeStClass { public: //********1******** //********2******** { NO = no; for (int i=0; strName [i] ! =0 ; i++) { Name [i] = strName [i] ; Name[i+1] = 0; } } void print() { //********3******** } TestClass () { //********4******** } }; int main () { TestClass stu; stu. Set (111,"Garfield"); stu.print(); return 0; }
进入题库练习
问答题综合应用题 使用VC6打开考生文件夹下的工程test16_3,此工程包含一个源程序文件test16_3.cpp,其中定义了类Cat,但类Cat的定义并不完整。请按要求完成下列操作,将类Cat的定义补充完整。 (1)定义类Cat的保护数据成员itsAge用于表示年龄,它是int型的数据。请在注释"//**1**"之后添加适当的语句。 (2)完成成员函数GetAge()的类外定义,返回成员的itsAge值,请在注释"//**2**"之后添加适当的语句。 (3)完成成员函数SetAge(int age)的类外定义,把数据成员itsAge赋值为参数age的值,请在注释"//**3**"之后添加适当的语句。 (4)完成成员函数Meow的类外定义,使其输出字符串"meow."到屏幕上。请在注释"//**4**"之后添加适当的语句。 输出结果如下: meow. kitty is a cat who is 5 years old. meow. 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件test16_3.cpp清单如下: #include class Cat { public: int GetAge(); void SetAge(int age); void Meow(); protected: //**1** }; int Cat::GetAge() { //**2** } void Cat::SetAge(int age) { //**3** } void Cat::Meow() { //**4** } void main() { Cat kitty; kitty.Meow(); kitty.SetAge(5); cout<<"kitty is a cat who is "; cout<
进入题库练习