计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有误,请改正其中的错误,使程序正常运行,并使程序在界面上输出为: 平均值为:29 最大值为:112 最小值为:-11 注意:错误的语句在//********error********的下面。修改该语句即可。#include<iostream>using namespace std;int main(){ int i,Ave,Min,Max; int data[8]={0,112,43,78,-11,-6,7,9}; Ave=0; for(i=0;i<8;i++) //********error******** Ave=data[i]; Ave/=8; cout<<"平均值为:"<<Ave<<endi; Max=Min=data[0]; for(i=0;i<8;i++) { //********error******** if(data[i]<Max)Max=data[i]; //********error******** if(data[i]>Min)Min=data[i]; } cout<<"最大值为:"<<Max<<endl; cout<<"最小值为:"<<Min<<endl; return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 0 注意:错误的语句在//*****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<<end1<<m.b<<end1;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹pmj2下的工程proj2,此工程包含有一个源程序文件proj2.cpp,其中定义了Stack类和ArrayStaek类。 Stack是一个用于表示数据结构“栈”的类,栈中的元素是字符型数据。Stack为抽象类,它只定义了栈的用户接口,如下所示: 公有成员函数 功能 push 入栈:在栈顶位置添加一个元素 pop 退栈:取出并返回栈顶元素 ArmySmek是Stack的派生类,它实现了Stack定义的接口。ArrayStack内部使用动态分配的字符数组作为栈元素的存储空间。数据成员maxSize表示的是栈的最大容量,top用于记录栈顶的位置。成员函数push和pop分别实现具体的入栈和退栈操作。 请在程序中的横线处填写适当的代码,然后删除横线,以实现上述功能。此程序的正确输出结果应为: a,b,c c,b,a 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 //pmj2.cpp #include<iostream> using namespaee std class Stack{ public: virtual void push(char c)=0; virtual char pop()=0; } ; class Arraystack:public Stack { char*p; int maxSize; int top; public: Arraystack(int s) { top=0; maxSize=s;//********found********p=________; } ~ArmyStack() {//********found********________;}void push(char c){ if(top == maxSize){ cellr<<"Overflow!\n"; returm; }//********found********________; top++; } char pop() { if(top==0){ cerr<<"Underflow!\n"; return '\0'; } top--;//********found********________;} }; void f(Stack& sRef) { char ch[]={'a','b','c'}; cout<<ch[0]<<","<<ch[1]<<","<<ch[2]<<endl; sRef.push(ch[0]);sRef.push(ch[1]);sRef.push(ch[2]); cout<<sRef.pop()<<","; cout<<sRef.pop()<<","; cout<<sRer.pop()<<endl;}int main(){ ArrayStack as(10); f(as); return 0; }
进入题库练习
问答题使用VC6打开下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并使程序输出的结果为:TestClass2TestClass3注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream>classTestClass1{public:virtualvoidfun()=0;};classTestClass2:publicTestClass1{//********error********intfun(){usingnamespacestd;cout"TestClass2"endl;}};classTestClass3:publicTestClass1{//********error********voidfun(){//********error********cout"TestClass3"endl;}};voidmain(){TestClass1*p;TestClass2obj1;TestClass3obj2;p=p->fun();obj2.fun();return;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹pmj2下的工程pmj2。其中有类Point(“点”)、lteetangle(“矩形”)和Circle(“圆”)的定义。在程序所使用的平面坐标系统中,x轴的正方向是水平向右的,y轴的正方向是竖直向下的。请在横线处填写适当的代码并删除横线,以实现上述类定义。此程序的正确输出结果应该是: 一一圆形一一一一 圆心=(3,2) 半径=1 面积=3.14159 一一外切矩形一一 左上角=(2,1) 右下角=(4,3) 面积 =4 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found*****”。#include<iostream>#include<cmath>using namespaoe std;//平面坐标中的点//本题坐标系统中,x轴的正方向水平向右,y轴的正方向竖直向下。class Point:{public: Point(double X=0.0,double y=0.0):x一(x),y一(y){) double getX()const{return x_;) double getY()const{return y_;) void setX(double x){x_=x;) void setY(double y){y_=y;)private: double x_; //x坐标 double y_;//y坐标};//矩形class Rectangle{public: Rectangle(Point P,int w,int h) :point(p),width(w),height(h) {} double area()const//矩形面积 { return width*height; } Point topLeft()const//左上角顶点 { return point; } Point bottomRight()const//右下角顶点(注:Y轴正方向竖直向下) { //**********found**********return Point(______);}private: Point point;//左上角顶点 double width;//水平边长度 double height;//垂直边长度 }; //圆形 class Circle{ public: Circle(Point P,double r):center(p),radius(r){) Rectangle.boundingBox()const;//外切矩形 double area()const//圆形面积 { //**********found********** return PI*______; }public: static const double PI;//圆周率private: Point center; //圆心 double radius; //半径 }; const double Circle::PI=3.14159; Rectangle Circle:: boundingBOx ()const { //**********found**********Point pt(_________);int w,h; //**********found********** W=h=______; return Rectangle(pt,W,h); } int main() { Point P(3,2); Circle c(p,1); cout<<”一一圆形一一一一一\nn; cout<<”圆心=(”<<P.getX() <<‘,’<<P.getY() <<”)\n”; cout<<”半径=”<<1<<endl; cout<<"面积="<<c.area() <<endl<<endl; Rectangle bb=C.boundingBox(); Point t1=bb.topLeft(); Point br=bb.bottomRight(); cout<<”一一外切矩形一一一一一\n”; cout<<”左上角=(”<<t1.getX() <<’,’<<t1.getY() <<”)\n”; cout<<”右下角=(”<<br.getX() <<’,’<<br.getY() <<”)\n”; cout<<”面积=”<<bb.area() <<endl; return 0; }
进入题库练习
问答题使用VC6打开下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为:Hello注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream.h>voidmain(){//********error********typedefBOOLbool;//********error********BOOLa=FALSE;inti=0X80000000;//********error********a=!i;if(a){cout"Hello"endl;}return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有误,请改正其中的错误,使程序正常运行,并使程序在界面上输出为: 平均值为:29 最大值为:112 最小值为:一11 注意:错误的语句在∥********error********的下面。修改该语句即可。#include<iostream>using namespace Std;int main(){ int i, Ave f Min F Max; int data[8]={0,1 1 2,4 3,7 8,一1 1,一6,7,9); Ave=0; for(i=0;i<8;i++) ∥********error******** Ave=data[i]; Ave/=8; cout<<“平均值为:”<<Ave<<endl; Max=Min=data[0]; for(i=0;i<8;i++) { ∥********error******** if(data[i]<Max)Max=data[i]; ∥********error******** if(data[i]>Min)Min=data[i]; } cout<<“最大值为:”<<Max<<endl; cout<<“最小值为:”<<Min<<endl; return 0;}
进入题库练习
问答题使用VC6打开 下的源程序文件modi2.cpp。阅读下列函数说明和代码。补充函数convert(long s,long *str),使之从低位开始取出长整型变量s中奇数位上的数,依次存放在数str中。 例如,当s中的数为:7654321时,str中的数为:7531。 注意:请勿改动主函数。 #include <iostream.h> void convert (long s,long *str) { } void main() { long s,res; cout "Please enter s:" endl; cin > > s; convert(s, cout "The result is:" res endl; return; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义类的私有变量a、b,请在注释∥********1********后添加适当的语句。 (2)完成类的构造函数,对变量a、b赋值,缺省两个变量值为1,在注释∥********2********之后添加语句。 (3)完成打印函数display(),打印出“a*b=c”格式的一个乘法算式,在注释∥********3********之后添加语句。 (4)补充主函数,使得打印9×9的乘法口诀。在注释∥********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打开考生文件夹下的源程序文件modi3.cpp,其中定义了用于表示人基本信息的类CHumanlnfo,但类CHumanlnfo的定义并不完整。请按要求完成下列操作,将类CHumanlnfo的定义补充完成: (1)定义私有数据成员bloodType用于表示血型,血型为char型的数据。请在注释“//********1********”之后添加适当的语句。 (2)完成构造函数的定义,要求具有缺省值,缺省值为身高175,体重70,血型A。请在注释“//********2********”之后添加适当的语句。 (3)完成类外CHumanInfo成员函数Setlnfo的定义。请在注释“//********3********”之后添加适当的语句。 (4)在主函数中调用成员函数Setlnfo,把对象d2的三个私有数据成员分别设定为身高170,体重64,血型为B。请在注释“//********4********”之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>Class CHumanInfo{private: int height; int weight; //********1********public: //********2******** :height(ht),weight(wt),bloodType(bt){); CHumanInfo(CHumanInfo &h1):height(h1.height), weight(h1.weight),bloodType(h1.bloodType){}; int GetHeight() { return height; } int GetWeight() { return welght; } int GetBloodType() { return bloodType; } void SetInfo(int ht,intwt,char bt); void Display();};//********3********{ height=ht; weight=wt; bloodType=bt;}void CHumanInfo::Display(){ cout<<"HumanInfo:"; cout<<height<<"cm, "<<weight<<"Kg,BloodType"<<bloodType<<endl;}Void main(){ CHumanInfo hl(169,61,'A'); CHumanInfo h2; CHumanInfo h3(h1); CHumanInfo h4(h2); //********4******** h1.Display(); h2.Display(); h3.misplay(); h4.misplay();}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: This object is no.1 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 //proj1.cpp #include <iostream> using namespace std; class MyClass public: MyClass ():count (0) cout<<"Thisobject is"; //ERROR ********found******** void Inc () const cout<<"no."<<++count<<endl; private: //ERROR ********found******** int count=0; ; int main () MyClass * obj=new MyClass; //ERROR ********found******** *obj.Inc(); return 0;
进入题库练习
问答题请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中声明了SorteList类。这是一个用于表示有序数据表的类,其成员函数insert的功能是将一个数据插入到有序表中,使得该数据表仍保持有序。请编写lnsert函数。程序的正确输出应该是: 1,2,4,5,7,8,10 插入6和3后: 1,2,3,4,5,6,7,8,10 要求:补充编制的内容写在//********333********与//料料料料666********两行之间,不得修改程序的其他部分。 注意:程序最后已经将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //源程序 #include"SortedList.h" SortedList:: SortedList(int len, double data[]):len(len) d=new double[len+2]; for(int k=0; k<len; k++) d[k]=(data==NULL?0.0:data[k]); for(int i=0; i<len-l,i++) int m=i; for(int j=i; j<len; j++) if(d[j]<d[m]) m=j; if(m>i) double t=d[m]; d[m]=d[i]; d[i]=t; void SortedList::insert(double data) //********333******** //********666******** void SortedList:: show () const //显示有序数据表 for(int i=0; i<len-1,i++) cout<<d[i]<<","; cout<<d[len-1]<<endl; int main() double s[]=5,8,1,2,10,4,7; SortedList list(7,s); cout<<"插入前:"<<endl; list.show(); list.insert (6.0); list.insert(3.0); cout<<"插入 6和 3后:"<<endl; list.show(); // writeToFile ("K: // b10 //61000101 // ",list) ; return 0,
进入题库练习
问答题使用VC6打开考生文件夹下的工程MyProj4。此工程包含一个源程序文件 MyMain4.cpp,该程序将通过把类Distance定义为类Point的友元类来实现计算两点之间距离的功能。但程序中定义的类并不完整。请按要求完成下列操作,把类的定义补充完整。 ①把类Distance定义为类Point的友元类。请在注释“//**1**”之后添加适当的语句。 ②定义类Point的构造函数,完成给私有数据成员x和y的赋值,并且两个参数的默认值都为0。请在注释“//**2**”之后添加适当的语句。 ③完成类Distance的成员函数Dis(Point class Point { public: / /* * 1 * * / /定义类 Point 的构造函数 / /* * 2 * * void pint() { cout<<"x="<<x<<end1; cout<<"y="<<y<<end1; } private: float x,y; }; class Distance { public: float Dis(Point }; float Distance :: Dis(Point Distance d; cout<<d.Dis(p,q)<<end1; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.epp,但该程序运行有问题,请改正main函数中的错误,使程序的输出结果是: nember=l nember=10 nember:100 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在∥********error********的下面。 #lnclude C1ass TeStClass { public: TestClass(int i){ nember=i; } void SetNember(int m){ nember=m; } int GetNember()const( return nember; } void Print()const{ cout<<“nember=”<
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中定义的IntArray是一个用于表示整型一维数组的类。成员函数swap可以将数组中的两个指定元素交换位置;成员函数sort的功能是将数组元素按照升序排序。请编写成员函数sort。在main函数中给出了一组测试数据,此时程序运行中应显示: 读取输入文件… ---排序前--- a1=3 1 2 a2=5 2 7 4 1 6 3 ---排序后--- a1=1 2 3 a2=1 2 3 4 5 6 7 要求: 补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数WriteToFile已经编译为obj文件,并且在本程序中调用。 //IntArray.h #include <iostream> #include <string.h> using namespace std; class IntArray { public: IntArray(unsigned int n) { size = n; data = new int[size]; } ~IntArray() { delete [] data; } int getSize() const { return size; } int } void swap(int i, int j) { int temp = data[i]; data[i] = data[j]; data[j] = temp; } void sort(); friend ostream i<array.getSize (); i++) os << array[i] << ''; return os; } private: int * data; unsigned int size; }; void readFromFile ( const char *, IntArray void writeToFile (char*, const IntArray //main.h #include <fstream> #include "IntArray. h" void IntArray::sort () { //******** 333******** //******** 666******** } void readFromFile (const char * f, IntArray if (infile.fail ()) { cerr << "打开输入文件失败!"; return; } int i=0; while (!infile.eof()) { infile >> m[i++]; } } int main () { IntArray a1(3), a2(7), a3(1000); a1[0]=3, a1[1]=1, a1[2]=2; a2[0]=5, a2[1]=2, a2[2]=7, a2[3]=4, a2[4]=1, a2[5]=6, a2[6]=3; readFromFile ("in.dat", a3); cout << "---排序前---/n"; cout <<"a1=" << a1 <<endl; cout <<"a2=" << a2 <<endl<<endl; al.sort (); a2.sort(); a3.sort(); cout <<"---排序后--- /n"; cout <<"a1=" <<a1<<endl; cout <<"a2=" <<a2<<endl<<endl; writeToFile("", a3); return 0; }
进入题库练习
问答题请使用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 j = 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; }
进入题库练习
问答题简单应用题 请编写两个函数void sort(int sort(a,b); sort(a,b,c); }
进入题库练习
问答题用VC6打开考生文件夹下的源程序文件modi3.cpp,这个程序完成输出到屏幕一些特定的信息,但工程有错误或者不完整,请完成以下功能: (1)初始化m Nurn2的值为i,请在注释//********1********后添加适当的语句。 (2)补充全局函数fun()使之能够调用类TestClass的成员变量,请在注释//********2********后添加适当的语句。 (3)初始化静态变量, 请在注释//********3********后添加适当的语句。 (4)修改注释//********4********后的语句。 使得程序输出以下内容: m_Num1=1 m_Num2=2 m_Num3=1 m_Num1=4 m_Num2=2 m_Num3=7 注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>Class TestClass{public: //********1******** TestClass(int i,int j) { m Num1=i; m Num3+=i; } void Print() { cout<<"m Num1 = "<<m Num1<<endl; cout<<"m Num2 = "<<m Num2<<endl; cout<<"m Num3 = "<<m Num3<<endl; } void Add(int i) { m Num3+=1; }private: int m Num1; const int m Num2; static int m Num3; //********2********};//********3********void fun(){ TestClass Num(1,2); Num.m Num1=4; //********4******** Num.Add(); Num.Print();}void main(){ TestClass Num(1,2); Num.Print(); fun(); return;}
进入题库练习
问答题使用VC6打开下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。其中:定义了类circle和column,column类由circle类protected派生,但是两个类的定义并不完整,请按照以下的要求,将程序补充完整。(1)定义类circle的保护数据成员函数r和area,它们都是double型的数据,请在注释//********1********后完成。(2)添加类circle的无参数的构造函数,使得类circle对象的r默认值为0,请在注释//********2********后完成。(3)添加派生类column的构造函数的定义,使得参数为double型的height和radius并将其分别赋给数据成员h和基类的r请在注释//********3********之后完成。(4)完成派生类column的成员函数print()的定义,请在注释//********4********之后完成,使得输出为:radius=5area=78.54height=10vol=785.4注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>constdoublepi=3.1416;classcircle{protected://********1********public://********2********{r=0.0;}circle(doubleradius){r=radius;}voidprint(){area=r*r*pi;cout"radius="r"""area="areaendl;}};classcolumn:protectedcircle{protected:doubleh;public://********3********{h=height;r=radius;}voidprint(){circle::print();//********4********}};intmain(){columncoi(5.0,10.0);col.print();return0;}
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数sum(int A[NUM][NUN],int n)的功能是计算矩阵中所有非质数数字的和。 提示:函数isPrime(int n)的功能是判定当前数字是否为质数,如果是则返回true。 注意:不能修改程序的其他部分,只能修改sum函数。 试题程序: #include<iostream.h> #include<cmath> #define NUM 50 int A[NUM][NUM]= 1,3,5,7,9, 11,13,15,17,19, 21,23,25,27,29, 31,33,35,37,39, 41,43,45,47,49 ; bool isPrime(int n) if(n==1) return false; if(n==2) return true; for(int i=2;i<n/2;i++) if(n%i==0) return false; return true; int sum(int A[NUM][NUM],int n) int main() cout<<sum(A,5)<<end1; return 0;
进入题库练习