计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: 30 130 注意:错误的语句在//*****error******的下面,修改该语句即可。#include<iostream.h>int a=10;class CObj{public: CObj() { a=b=0; } void display() { //*****error****** cout<<a<<b<end1; ) void func(int a) { //*****error****** a+=a; } void func2() { //*****error****** a+=a; )private: int a,b;};void main(){ CObj obj; obj.func(3); obj.display(); obj.func2(); obj.display();}
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: CMyObject,in the construtor ~CMyObject,in the destrutor 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> class CMyObject //******error****** //******error****** CMyObject{cout "CMyObject, in the construtor" endl;} ~CMyObject() {cout "~CMyObject, in the destrutor" endl;} }; void main() { CMyObject obj1; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹pmj3下的工程文件proj3,此工程中包含一个源程序文件proj3.cpp,其中定义了用于表示平面坐标系中的点的类MyPoint和表示矩形的类MyRectangle;程序应当显示: (0,2)(2,2)(2,0)(0,0)4 但程序中有缺失部分,请按照以下提示,把缺失部分补充完整: (1)在“//**1**,****found****”的下方是构造函数的定义,它用参数提供的左上角和右下角的坐标对up_left和down_right进行初始化。 (2)在“//**2** ****found****”的下方是成员函数getDownLeft的定义中的一条语句。函数getDownLeft返回用MyPoint对象表示的矩形的左下角。 (3)在“//**3** ****found****”的下方是成员函数area的定义,它返回矩形的面积。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“****found****”。//proj3.cpp#include<iostream>using namespace std;class MyPoint{//表示平面坐标系中的点的类 double x; double Y;public: MyPoint(double x,double y){this->x=x;this->Y=Yj) double getX()const{return x;} double getY()const{return Y;} void show()const{cout<<’(’<<x<<’,’<<y<<’)’;}};class MyRectangle{ //表示矩形的类 MyPoint up_left; //矩形的左上角顶点 MyPoint down_right;//矩形的右下角顶点public:MyRectangle (MyPoint upleft, My-Point downright); MyPoint getUpLeft()const{return up_left;) //返回左上角坐标 MyPo int getDownRight()cons t{ return down right;) //返回右下角坐标 MyPoint getUpRight()Const;//返回右上角坐标 MyPoint getDownLeft()const;//返回左下角坐标 double area()const;//返回矩形的面积 }; //**1** **********found********** MyRectangle::MyRectangle(__________): up_left(p1),down_right(p2){)MyPoint MyRectangle:: getUpRight()const{ return MyPoint(down_right.getX(),up_left.getY());}MyPoint MyRectangle:: getDOwnLeft()const{ //**2** **********found********** return MyPoint(________);}//**3** ********found*********________area()const{ return(getUpLeft().getX()一get- DownRight().getX())* (getDownRight ().getY()一getUpLeft().getY()); } int main() { MyRectangle r(MyPoint(0,2),MyPoint (2,0)); r.getUpLeft().show(); r.getUpRight().show(); r.getDownRight().show(); r.getDownLeft().show(); couut<<r.area()<<endl; 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打开考生文件夹下的源程序文件modi2.cpp。请补充完整程序fun(int i),使程序完成以下功能: 如果i=5,则输出如下5行井号。 # ## ### #### ##### 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 #include void fun(int i) { } int main() { fun(5); return 0; }
进入题库练习
问答题请编写函数fun(),其功能是计算并输出当x<0.97时下列多项式的值,直到|Sn-Sn-1|<0.000001为止。 Sn=1+0.5x+0.5(0.5-1)x2/2!+0.5(0.5-1)(0.5-2)x3/3!+…0.5(0.5-1)(0.5-2)…(0.5-n+1)xn/n! 例如:主函数从键盘给x输入0.21后,则输出为s=1.100000。 注意:部分源程序以存在文件test38_2.cpp中。 请勿改动主函数main和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 文件test38_2.cpp的内容如下: #include<stdio.h> #include<iostream.h> #include<math.h> double fun(double x) { } void main( ) { double x, s; cout<<"Input x:"<<endl; cin>>x; s=fun(x); cout<<"s="<<s<<endl; }
进入题库练习
问答题简单应用题 请编写一个函数int fun(int nFirst,int nSecond),求两个数的最小公倍数并返回这个值。 注意:部分源程序已存在文件test13_2.cpp中。如输入7和8时,结果是56。 请勿修改主函数main和其他函数中的任何内容,仅在函数fun的花括号中填写若干语句。 文件test13_2的内容如下: #include int fun(int nFirst,int nSecond); void main() { int nFirst, nSecond; cout>nFirst; cout>nSecond; cout<<"最小公倍数:"<
进入题库练习
问答题综合应用题 使用VC6打开考生文件夹下的工程test6_3,此工程包含一个源程序文件test6_3.cpp,其中定义了用于表示考生的类Student,请按要求完成下列操作,将程序补充完整。 (1)定义私有数据成员code、english分别用于表示考生的编号、英语成绩、它们都是int型的数据。请在注释"//**1**"之后添加适当的语句。 (2)完成成员函数void Student::inputinformation()的定义,该函数用于用户输入一个考生对象的信息,输入格式如下所示: 输入编号: 英语成绩: 计算机成绩: 请在注释"//**2**"之后添加适当的语句。 (3)利用已实现的类Student的成员函数,完成函数void firstname(Student *A[],int num)的定义,该函数根据考生信息A[],输出num个考生中总分最高者的编号及其相应的总分,在此不考虑总分相同的情况。请在注释"//**3**"之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件test6_3.cpp清单如下: #include class Student { //**1** int computer; int total; public: void getinformation(); void computesum(); int getcode(); int gettotalscore(); ~Student(); }; void Student::getinformation() { //**2** cout>english; cout>computer; } void Student::computesum() { total=english+computer; couttempsum) { tempcode=(*A[i]).getcode(); tempsum=(*A[i]).gettotalscore(); } } coutgetinformation(); } for(i=0;icomputesum(); } firstname(A,3); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错误,请改正程序中的错误,使得程序输出: 1, 2, 3, 4, 5, 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>Class TestClass{ //********error TestClass(int i) { m_i =i; } void print() { cout<<++m i<<','; }public: int m_i;); int main(){ //********error******** int i(); TestClass data(0); while(i>5) { //********error******** i++; data.print(); } cout<<endl; return 0;}
进入题库练习
问答题请编写函数fun(),其功能是将s所指字符串中除了下标为奇数、同时ASCII值也为奇数的字符之外,其余的所有字符都删除。字符串中剩余的字符所形成的一个新的字符串放在t所指的数组中。 例如:s所指字符串中的内容为ABCDEFG12345,其中字符A,的ASCII码值虽为奇数,但元素所在的下标为偶数,因此必需删除;字符1的ASCII码值为奇数,所在数组中的下标也为奇数,不删除,最后t所指的数组中的内容应是135。 请勿修改主函数main和其他函数中的任何内容,仅在函数su的花括号中填写若干语句。 文件test 27_2.cpp的内容如下; #include <conio.h> #include <stdio.h> #include <iostream.h> #include <string.h> void fun(char *s,char t[ ]) void main ( ) char s[100],t[100]; cout<<"Please enter string S: "<<end1; gets(s); fun(s, t); puts(t);
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1,该工程中包含程序文件main.cpp,其中有关TVSet(“电视机”)和主函数main的定义。程序中位于每个“// ERROR ********found********”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: 规格:29英寸,电源:开,频道:5,音量:18 规格:29英寸,电源:关,频道:-1,音量:-1 注意:只修改每个“// ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> using namespace std; class TVSet{ //“电视机”类 const int size; int channel; //频道 int volume; //音量 bool on; //电源开关:true表示开,false表示关 public: // ERROR *******found******* TVSet(int size) { this -> size(size); channel = 0; volume = 15; on = false; } int getSize() const {return size;} //返回电视机规格 bool isOn() const {return on;} //返回电源开关状态 //返回当前音量,关机情况下返回-1 int getVolume() const {return isOn()? volume:-1;} /返回当前频道,关机情况下返回-1 int getChannel() const {return isOn()? channel: -1;} // ERROR *******found******* void turnOnOff() const //将电源在“开”和“关”之间转换 {on=! on;} void setChannelTo (int chan){ //设置频道(关机情况下无效) if (isOn() } void setVolumeTo (int vol){ //设置音量(关机情况下无效) if(isOn() } void show_state() { // ERROR *******found******* cout << "规格:" << getSize() << "英寸" << ",电源:" << (isOn()? "开":"关") << ",频道:" << getChannel() << ",音量:" << getVolume() << endl; } }; int main() { TVSet tv(29); tv.turnOnOff(); tv.setChannelTo(5); tv.setVolumeTo(18); tv.show_state(); tv.turnOnOff(); tv.show_state(); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)基类Person完成打印功能,定义其中的打印函数为虚函数,请在注释∥********1********后添加适当的语句。 (2)类Man继承于Person,在构造函数中设置性别为l,请在注释∥********2********后添加适当的语句。 (3)类Woman继承于Person,在构造函数中设置性别为0,请在注释∥********3********后添加适当的语句。 (4)实现函数fun(),用于传递不同的类型,打印出性别,请在注释∥********4********后添加适当的语句。 输出的内容如下: Sex=Man Sex=Woman 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include Class Person { public: ∥********1******** void print()(); int sex; }; class Man:public Person { public: Man() { ∥********2******** } void print(){ cout<<“Man”<
进入题库练习
问答题请编写一个函数char MaxCharacmr(char *str),该函数返回参数str所指向的字符串中具有最大ASCII码的那个字符(如字符串“world”中字符‘w’具有最大的ASCII码)。当str所指向的字符串为空时,则返回空字符0x0或‘/0’。 输出结果如下: Good Morning! Max char:r 注意:部分源程序已存在文件test15_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数MaxCharacter的花括号中填写若干语句。 文件test15_2.cpp的内容如下: #include<iostream.h> #include<string.h> char MaxCharacter(char *str); void main() char str[100]; strcpy(str,"Good Morning!"); char maxc=MaxCharacter(str); cout<<str<<endl; cout<<"Max char:"<<maxc<<endl; char MaxCharacter(char*str)
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序,使函数fun()实现以下功能:找出一个整数,它加上100后是一个完全平方数,再加上268又是一个完全平方数,请问该数是多少? 程序分析:在10万以内判断,先将该数加上100后再开方,再将该数加上268后开方,如果开方后的结果满足条件,即是结果。 #include #include void fun() { } int main() { fun(); return 0; }
进入题库练习
问答题使用VC6打开下的源程序文件modi1.cpp,该程序运行时有错误,请改正程序中的错误,使得程序运行后没有内存遗漏。可以在修改处增加或者删除一条语句。本程序完成输入两个字符串,分别存储到s1,s2中。注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。#include<iostream.h>voidmain(){char*s1;chars2[1024];//********error********cin.getline(s1,1024);cin.getline(s2,1024);//********error********deletes1;//********error********deletes2;return;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj3下的工程文件proj3。本题创建一个小型字符串类,字符串长度不超过100。程序文件包括proj3.h、proj3.cpp、writeToFile.obj。补充完成重载赋值运算符函数,完成深复制功能。 屏幕上输出的正确结果应该是: Hello! Happy new year! 要求: 补充编制的内容写在“// ********333********”与“// ********666********”两行之间。不得修改程序的其他部分。 注意: 程序最后调用writeToFile函数,使用另一组不同的测试数据,将不同的运行结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件。 //proj3.h #include <iostream> #include <iomanip> using namespace std; class MiniString { public: friend ostream return output;} friend istream //用于输入的临时数组 temp[0] = "/0"; //初始为空字符串 input >> setw(100) >> temp; int inLen = strlen(temp); //输入字符串长度 if(inLen ! = 0) { s.length = inLen; //赋长度 if (s.sPtr! = 0) delete[]s.sPtr; //避免内存泄漏 s.sPtr = new char[s.length +1]; strcpy(s.sPtr, temp); //如果s不是空指针,则复制内容 } else s.sPtr[0] = "/0"; //如果s是空指针,则为空字符串 return input; } void modString(const char * string2 ) //更改字符串内容 { if (string2 ! = 0) //如果string2不是空指针,则复制内容 { if (strlen(string2) ! = length) { length = strlen (string2); delete []sPtr; sPtr = new char [length +1]; //分配内存 } strcpy(sPtr, string2); } else sPtr [0] = "/0"; //如果string2是空指针,则为空字符串 } MiniString MiniString (const char * s = " "):length((s ! = 0) ? strlen(s):0) //构造函数 { s Ptr = 0; if (length! =0) setString(s); } ~MiniString() //析构函数 {delete [] sPtr;} private: int length; //字符串长度 char * sPtr; //指向字符串起始位置 void setString(const char * string2) //辅助函数 { sPtr = new char[strlen(string2) +1]; //分配内存 if(string2 ! = 0) strcpy(sPtr, string2); //如果string2不是空指针,则复制内容 else sPtr[0] = "/0"; //如果string2是空指针,则为空字符串 } }; //proj3.cpp #include <iostream> #include <iomanip> using namespace std; #include "proj3.h" MiniString void writeToFile(const char *); str2 = str1; //使用重载的赋值运算符 str2.modString ("Happy new year!"); cout << str1 << "/n"; cout << str2 << "/n"; writeToFile (" "); return 0; }
进入题库练习
问答题请使用“答题"菜单或使用VC6打开考生文件夹proj1下的工程proj1,该工程含有一个源程序文件proj1.cpp。程序中位于每个//ERROR************found************下的语句行有错误。请改正这些错误,改正后程序的输出应该是: 1 2 3 4 5 6 7 8 9 10 注意:只修改注释//ERROR************found************下的一行语句,不要改动程序中的其他内容。 //源程序proj1.cpp #include<iostream> using namespace std; class MyClass public: MyClass(int len) array=new int[len]; arraySize=len; for(int i=0;i<arraySize; i++) array[i]=i+l; ~MyClass() //ERROR************found************ delete array[]; void Print() const for(int i=0;i<arraySize; i++) //ERROR************found************ cin<<array[i]<<"; cout<<endl; prlvate: int*array; int arraySize; ; int main() //ERROR************found************ MyClass obj; obj.Print(); return 0:
进入题库练习
问答题请使用VC6或使用[答题] 菜单打开考生文件夹proj1下的工程proj1,此工程中包含一个源程序文件main. cpp,其中有类Book(“书”)和主函数main的定义。程序中位于每个“//ERROR****found****”下的语句行有错误,请加以改正。改正后程序的输出结果应该是: 书名:C++语句程序设计总页数:299 已把“C++语言程序设计”翻到第50页 已把“C++语言程序设计”翻到第51页 已把“C++语言程序设计”翻到第52页 已把“C++语言程序设计”翻到第51页 已把书合上。 当前页:0 注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。 #include < iostream > using namespace std; class Book char * title ; int hum_pages; //页数 int cur_page; //当前打开页面的页码,0表示书未打开 public : // ERROR ********** found ********** Book ( const char * theTide, int pages) num_pages (pages) tide = new char[ strlen(theTifle) + 1 ] ; strcpy ( tide, theTitle ) ; cout << endl << " 书名:" << title << "页面数:" << num_pages ; ~Book() delete []title; bool isClosed () const return cur_page == 0 ; //书合上时返回true,否则返回false bool isOpen()const return ! isClosed() ; //书打开时返回true,否则返回false int numOfPages () const return num_pages ; /返回书的页数 int currentPage()const return cur_page; //返回打开页面的页码 // ERROR ********** found ********** void openAtPage(int page_no) const //把书翻到指定页 cout << endl ; if( page_no < 1 || page_no > num_pages) cout << "无法翻到第" << cur_page << " 页。" ; close () ; else cur_page = page_no ; cout << "已把" "<< title << " "翻到第" << cur page << "页" ; void openAtPrevPage() openAtPage(cur_page - 1); //把书翻到上一页 void openAtNextPage() openAtPage(cur_page + 1 ) ; //把书翻到下一页 void close() //把书合上 cout << endl ; if( isClosed() ) cout << "书是合上的。" ; else //ERROR ********** found ********** num_pages = 0 ; cout << "已把书合上。" ; cout << endl; ; ; int main() Book book( "C ++ 语言程序设计", 299) ; book. openAtPage (50) ; book. openAtNextPage () ; book. openAtNextPage () ; book. openAtPrevPage () ; book. close () ; cout << "当前页:" << book. currentPage() << endl; return 0 ;
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并使程序的执行结果为: 1 2 3 4 5 4 3 2 1 1 2 3 4 3 2 1 1 2 3 2 1 1 2 1 1 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> #include<iomanip.h> void main() { int i,j,k; for(i=5;i>=1;i--) { /******error****** for(j=1;j<=i;j++) cout " "; //******error****** for(k=1;k>=i;k++) cout setw(3) k; //******error****** for(k=i-1;k>0;k++) cout setw(3) k; cout endl; } }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)定义类CPlanet的保护数据成员distance和revolvePeriod,它们分别表示行星距太阳的距离和行星的公转周期。其中,distance为double型,revolvePeriod为int型。请在注释//********1********之后添加适当的语句。 (2)定义类CEarth的构造函数CEarth(double d,intr),并在其中计算地球绕太阳公转的轨道周长。假定:circumference=2*d*3.1416。请在注释//********2********之后添加适当的语句。 (3)定义类Earth的成员display(),用于显示所有信息。包括地球距太阳的距离,地球的公转周期,以及地球绕太阳公转的轨道周长。请在注释//********3********之后添加适当的语句。 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream>using namespace std;Class CPlanet{protected: //********1********public: CPlanet(double d,int r) { distance=d; revolvePeriod=r; }};class CEarth:public CPlanet{ double Circumference,public: //********2******** CEarth(double d,int r) { circumference=2*d*3.1416; } //********3******** { cout<<"distance="<<distance<<endl; cout<<"revolutionPeriod="<<revolvePeriOd<<endl; cout<<"revolutioncircumference="<<circumference<<endl; }};void main(){ CEarth earth(9300000,365); earth.display();}
进入题库练习