计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开下的源程序文件modi2.cpp。请完成函数fun(char*s),该函数完成以下功能:(1)把s中的大写字母转换成小写字母,把其中的小写字母转换成大写字母。并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。例如:s="helloTEST",则结果为:s="HELLOtest"(2)完成函数WriteFile(char*s),把字符串输入文件中。提示:打开文件使用的第二参数为ios_base::binary|ios_base::app。注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。#include<iostream>#include<fstream>#include<cmath>usingnamespacestd;voidWriteFile(char*s){}voidfun(char*s){}voidClearFile(){ofstreamout1;out1.open("modi2.txt");out1.ciose();}intmain(){ClearFile();chars[1024];cin.getline(s,1024);fun(s);return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.clap,该程序运行时有错误,请改正错误,使得程序输出: Hello test 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。#include<iostream>//********error********template<T>void fun(T t){ std::cout<<''test''<<std::endl;}//********error********template<bool>void fun(bool t){ std::cout<<(t?''Hello'':''Hi'')<<std::endl;}int main(){ //********error******** bool flag=TRUE; fun(flag);fun((int)flag); return 0;}
进入题库练习
问答题编写函数fun(),该函数的功能是从字符串中删除指定的字符,同一字母的大、小写按不同字符处理。 例如:程序执行时输入字符串为turbo c and borland c++,从键盘上输入字符n,则输出后变为turbo c ad borlad c++。 如果输入的字符在字符串中不存在,则字符串照原样输出。 注意:部分源程序已存在文件test18_2.cpp中。 请勿改动主函数脚in和其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 文件test18_2.cpp的内容如下: #include<stdio.h> #include<iostream.h> #include<conio.h> void fun(char s[ ], int c) void main ( ) static char str[ ]="turbo c and borland c++"; char ch; cout<<"原始字符串:/n"<<str<<end1; cout<<"输入一个字符:"; cin>>ch; fun(str.ch); cout<<"str="<<str<<end1;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,此工程包含有一个源程序文件proj2.cpp,其中定义了Stack类和ArrayStack类。 Stack是一个用于表示数据结构“栈”的类,栈中的元素是字符型数据。Stack为抽象类,它只定义了栈的用户接口,如下所示: 公有成员函数 功能 push 入栈:在栈顶位置添加一个元素 pop 退栈:取出并返回栈顶元素 ArrayStack是Stack的派生类,它实现了Stack定义的接口。ArrayStack内部使用动态分配的字符数组作为栈元素的存储空间。数据成员maxSize表示的是栈的最大容量,top用于记录栈顶的位置。成员函数push和pop分别实现具体的入栈和退栈操作。 请在程序中的横线处填写适当的代码,然后删除横线,以实现上述功能。此程序的正确输出结果应为: a,b,C C,b,a 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****料found****”。 //proj2.cpp #include using namespacc std; class Stack{ public: virtual void push(char C)=0; virtual char pop()=0; }; class ArrayStack:public Stack{ char*P; int maxSizc; int top; public: ArravStack(int s) { top=0; maxSize=s: //*********found********* P=______; } ~ArrayStack() { //*********found********* _______; } void push(char c) } if(top==maxSize){ cerr<<”Overflow! \n”: return; } //*********found********* _______; top++: } char pop() { if(top==0){ cerr<<”Underflow!、n”; return‘\0’; } Top--; //*********found********* ______; } }; void f(Stack&sRef) { char ch[]={‘a’,‘b’,‘c’}; cout<
进入题库练习
问答题使用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后添加适当的语句。 注意:增加或者修改代码的位置已经用符号表示出来,请不要修改其他的程序代码。 试题程序: #included<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或使用【答题】菜单打开考生文件夹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 lows,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<lows;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<lows*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或使用【答题】菜单打开考生文件夹pmj1下的工程pmj1,此工程中含有一个源程序文件pmj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: The value is:10注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。//proj1.cpp#include<iostream>using namespace std;class Member {//ERROR********found********private: Member(int val):value(val){}. int value; }, class MyClass{ Member m;public://ERROR********found******** MyClass(int val){} int GetValue()const{return m.value;)};int main(){ MyClass*obj=new MyClass(i0); //ERROR********found******** 下列语句输出obj指向类中的value值 cout<<”The value is:”<<obj.GetValue()<<endl; delete obj; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成CMyClass的构造函数,请改正注释∥********1********后的错误。 (2)完成mnc0函数定义,请改正注释∥********2********后的错误。 (3)初始化CmyClass的成员变量Number3为4,请改正注释∥********3********后的错误。 (4)完成func()函数, 请改正注释∥********4********后的错误。 输出的结果为: Number1=12 Number2=18 Number3=16 Number1=4 Number2=2 Number3=19 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include class CMyClass { public: ∥********1******** CMyClass(int i,int j) { Number1=i; Number3+=i; } void display() { cout<<“Number1=”<
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“//ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: Base:Good Luck! Derived:Good Luck! 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 //praj1.cpp #include <iostream> #include <cstring> using namespace std; class Base { // ERROR ******** found******** private: char* msg; public: Base(char* str) { // ERROR ******** found******** msg:new char[strlen(str)]; strcpy (msg, str); cout << "Base: " <<msg << endl; } // ERROR ******** found******** ~Base() { delete msg; } }; class Derived:public Base { public: Derived (char* str):Base(str) {} void Show () { cout <<"Derived:" <<msg << endl; } }; int main ( ) { Derived obj ("Good Luck! "); obj.Show(); return 0; }
进入题库练习
问答题请使用“答题”菜单或使用VC6打开考生文件夹proj3下的工程proj3,其中声明了MagicNumber:类,该类是一个用于表示连续正整数序列的类。MagicNumber的成员函数Nar-cissistic的功能是查找该序列中的水仙花数水仙花数是指一个n位数(11>=3),其每个位上的数字的n次方之和等于该数本身,例如153就是一个3位的水仙花数(153=1*1*1+5*5*5+3*3*3)).请编写成员函数Narcissistic。在main函数中给出了一组测试数据,若输入3,此时程序的输出应该是:3位的水仙花数共4个:153370371407注意:只需在//**********333**********和//**********666**********之间填入所编写的若干语句,不要改动程序中的其他内容。#include”MagicNumber.h”void MagicNumber::Narcissistic(){ int i,number,sum,figures[30]; for(number=min;number<max;number++){int X=number;i=0;while(X!=0){figures[i]=x%i0,i++;x/=i0;}//**********333**********//**********666**********} } int main() {int d;cout<<”请输入位数:cin>>d;MagicNumber obj(d);obj.Narcissistic();obj.Print(string(”水仙花数”)>;writeToFile(”C:\\test\\.-);return 0;}//proj3\MagicNumber.h#include<iostream>#include<string>#include<cmath>using namespace std;clas s MagicNumber{public: MagicNumber(int d):digits(d),min(pow(i0,digits一1)),max(pow(i0,digits)一.1),count(0){) MagicNumber(int xl,int x2):min(x1),max(x2){}void ResetCount(){count=0 ;}int GetCount()const{returncount;)int GetSet(int index){return set[index];}void Narcissistic(); //查找水仙花数 void Print(string&str) {cout<<digits<<”位的”<<str<<”共”<<count<<”个:”<<endl;for(int i=0;i<count;i++)cout<<set[i]<<endl;}private: int digits;//Magic数的位数 int min,max; //待计算的数值范围 int count; //Magic数的数量 int set[20];//Magic数集合};void writeToFile(const char*);
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并使程序输出的结果为: TestClass2 TIestClass3 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream>Class TestClass1{public: virtual Void fun()=0;};class TestClass2:public TestClass1{ //********error******** int fun() { using namespace Std; cout<<"TestClass2"<<endl; }};class TestClass3:public TestClass1{ //********error******** void fun() { //********error******** Cout<<"TestClass3"<<endl; }};Void main(){ TestClassl*p; TestClass2 obj1; TestClass3 obj2; P=&obj1; P=>fun(); obj2.fun(); return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。完成空出的函数fun(int a[],int*index),使函数输入n( #defime MAXLINE 100 int fun(int a[],int*index) { } void main() { int A[MAXLINE]; int index; int maxdata; maxdata=fun(A,&index); cout<<“the max data iS:”<< maxdata<<“”<<”the posion is:”<< index<
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程文件proj3。本题创建一个小型字符串类,字符串长度不超过l00。程序文件包括pmj3.h、proj3.cpp、writeToFile.obj。补充完成重载赋值运算符函数,完成深复制功能。 屏幕上输出的正确结果应该是: Hello! Happy new year! 补充编制的内容写在“//**********333**********”与“//**********666**********”两行之间。 不得修改程序的其他部分。 注意: 程序最后调用writeToFil。函数,使用另一组不同的测试数据,将不同的运行结果输出到文件0ut?dat中。 输出函数writeToFile已经编译为obj文件。 //proj3.h #include #include using namespace std; class MiniString { pubhc: friend。8tream&operator>(istream&input,MiniString&8)//重载流提取运算符 { char temp[100];//用于输入的临时数组 temp[0]=’/0’://初始为空字符串 input>>setw(100)>>temp; int inLen=strlen(temp);//输入字符串长度 if(inLen!=0) } s.1ength=inLen;//赋长度 if(s.sPtr!=0)delete[]s.sPtr;//避免内存泄漏 s.sPtr=Hew char[s.1ength+1]; strcpy(s.sPtr,temp);//如果8不是空指针,则复制内容 } else s.sPtr[0]=’/0’;//如果s是空指针,则为空字符串 retum input; } void modString(const char}string2)//更改字符串内容 { if(strin92 1=0)//如果strin92不是空指针,则复制内容 { if(strlen(strin92)!=length) { length=strlen(strin92); delete[]sPtr; sPtr=new char[1ength+1];//分配内存 } strcpy(sPtr,strin92); } else sPtr[0]=’\0’;//如果string2是空指针,则为空字符串 } MiniString&operator=f const MiniString&otherString); MiniString(corot char*s=""):lengtll((s!=0)?strlen(s):0)//构造函数 { sPtT=0: if(1ength[=0) setString(S); } ~MiniString()//析构函数 {delete[]sPtr;} private: int length;//字符串长度 char*sPtr;//指向字符串起始位置 void setString(const char*string2)//辅助函数 { sPtr=Dew char[str|en(string2)+1];//分配内存 if(stnIl92!=0)strcpy(sPtr,string2);//如果string2不是空指针,则复制内容 else slur[0]='/0';//如果string2是空指针,则为空字符串 } }; //pwj3.cpp #'include #include using namespace std; #include”proj3.h” MiniString&MiniStrin9::0perator=(const MiniString&otherString) {//重载赋值运算符函数。提示:可以调用辅助函数setString //*************333********** //*************666********** } int main() { MiniSu'ing strl(”Heuo!”),str2; void writeToFile(const char*); sir2=strl;//使用重载的赋值运算符 str2.modString("Happy new year!"); cout<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成函数fun(int x),该函数功能是将x的值转换成二进制数输出到屏幕,并且在函数中调用写函数WriteFile()将结果输出到modi2.txt文件中。 例如:x=13,13的二进制数字为1101,则输出到屏幕的为1101。 注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。 #include<iostream> #include<fstream> #include<cmath> using namespace std; void WriteFile(char*str) { orstream out1; out1.open(''modi2.txt",ios_base::binary|ios._base::app); for(int i=0;str[i]!=0;i++) out1.put(str[i]); out1.close(); } void ftm(int x) { } void ClearFile() { ofstream out1; out1.open(''modi2:txt''); out1.close(); } intmain() { ClearFile(); fun(13); return 0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1,此工程中包含了类Pets(“宠物”)和主函数main的定义。程序中位于每个“//ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: Name:sonny Tvpe:dog Name:John Type:dog Name:Danny Type:cat Name:John Type:dog 注意:只修改每个“// ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> using namespace std; enum Pets_type {dog, cat, bird, fish}; class Pets { private: char * name; Pets_type type; public: Pets (const char * name = "sonny", Pets_type type = dog); Pets ~Pets(); void show() const; }; Pets::Pets (const char * name, Pets_type type) //构造函数 { this -> name = new char[strlen(name) + 1]; strcpy(this -> name, name); // ERROR *******found******* type = type; } Pets:: ~Pets() //构造函数,释放name所指向的字符串 { // ERROR *******found******* name = "/0"; } Pets delete []name; name = new char [strlen (s.name) + 1]; // ERROR *******found******* strcpy (this -> name, name); type = s.type; return * this; } void Pets::show() const { cout << "Name:" << name << "Type:"; switch (type) { case dog: cout << "dog"; break; case cat: cout << "cat"; break; case bird: cout << "bird"; break; case fish: cout << "fish"; break; } cout << endl; } int main() { Pets mypet1, mypet2 ("John", dog); Pets youpet("Danny", cat); mypet1.show(); mypet2.show(); youpet.show(); youpet = mypet2; youpet.show(); return 0; }
进入题库练习
问答题使用VC6打开 proj1下的工程proj1,其中定义了一个CD类。程序中位于每个//ERROR**********found**********下的语句行有错误,请加以更正,不得修改程序的其他部分。更正后程序的输出应该是: 歌唱祖国 30 义勇军进行曲 95 注意:只能修改每个//ERROR**********found**********下的那一行,不要改动程序中的其他内容。 #include<iostream> #include<cstring> using namespace std; class CD { char name[20]; int number; public: void init(char*aa,int bb) { //ERROR*****found***** name=aa; number=bb; } char*getName(){ //ERROR*****found***** return*name; } int getNumber(){return number;) void output(){ //ERROR*****found***** cout<<name[20]<<""<<number<<endl; } }; void main() { CD dx,dy; dx.init("歌唱祖国",30); dy.init("义勇军进行曲",3*dx.getNumber()+5); dx.output(); dy.output(); }
进入题库练习
问答题使用VC++6.0打开下的源程序文件2.cpp。完成函数fun(char*s, int a[]),其功能是把字符串s中的数字提取出来存储在a[]中,然后返回数字的个数。 例如s="1234abedef567",则a[]中存储着1234567,返回7。 注意:不能修改程序的其他部分,只能修改fun函数。 试题程序: #include<iostream.h> int fun(char*s, int a[]) { } int main() { int a[1024]; int len fun("1234abcdef567", a); for(int i=0; i<len; i++) { cout<<a[i]<<''; } cout<<endl; cout<<i<<endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使程序正常运行,并使程序输出的结果为: TestClass2 TestClass3 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#include<iostream>Class TestClass1{public: virtual void fun()=0;};class TestClass2:public TestClass1{ //********error******** int fun() { using namespace std; cout<<"TestClass2"<<end1; } }; class TestClass3:public TestClass1 { //********error******** void fun() { //********error******** cout<<"TestClass3"<<end1; } }; void main() { TestClass1* p; TestClass2 obj1; TestClass3 obj2; p=&obj1; p->fun(); obj2.fun(); 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 Class 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打开下的源程序文件modi3.cpp。请完成以下部分,实现在屏幕上输出为:TestClass3TestClass2这个程序需要修改的部分,请按照以下部分实现。(1)类TestClass0不能被实例化,请定义一个纯虚函数print,在注释//********1*********后添加适当的语句。(2)类TestClass1私有虚继承类TestClass0,请在注释//********2*********后添加适当的语句。(3)类TestClass2公有继承类TestClass0,请在注释//********3*********后添加适当的语句。(4)类TestClass3公有继承类TestClass2与TestClass1,请在注释//********4*********后添加适当的语句。注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>classTestClass0{//********1********};//********2********classTestClass1:{public:voidprint(){}};//********3********classTestClass2:{public:voidprint(){;}};//********4********classTestClass3:{public:voidprint(){;}};voidmain(){TestClass3c3;TestClass2c2;c3.print();c2.print();return;}
进入题库练习