计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程pmjl,此工程中包含了类Pets(“宠物”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: Name:sonny Type:dog Name:John Type:dog Name:Danny Type:eat Name:John Type:dog 注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>using namespace st:d;enllm Pets type{dog,cat,bird,fish};class PetS{private: char*name; Pets_type type;public: Pets(const char*flame=”sonny”,Pets_type type=dog); Pets&operator=(const Pets&s); ~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&Pets::operator=(const Pets &s) { if(&s=this)//确保不要向自身赋值 return*this; 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打开考生文件夹下的源程序文件modi2.cpp。请实现函数fun(double b[],int len)的如下功能:(1)b[]是一个数组,长度为len;(2)b[0]=0,b[1]=1;(3)b[i+2]=b[i]+b[i+1];注意:请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。#include<iostream>void fun(double b[],int len){}void main(){double b[128];fun(b,128);for(int i=0;i<128;i++){std::cout<<b[i]<<' ';if(i%6==5)std::cout<<std::endl;}return;}
进入题库练习
问答题用VC6打开考生文件夹下的源程序文件modi.3.cpp。其中定义的类并不完整,按照要求完成下列操作,将类的定义补充完整。在屏幕和程序modi3.txt文件中输出以下结果:HelloTest出现异常情况其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整:(1)以追加的方式打开文件modi3.txt,请在注释//********1********后添加适当的语句。(2)定义一个类对象S,请在注释//********2********后添加适当的语句。注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>#include<fstream>using namespace std;void WriteFile(char*x){ofstream out1;//********1********out1.open("modi3.txt",);out1<<x<<' ';out1.close();}void ClearFile(){ofstream out1;out1.open("modi3.txt");out1.close();}class TestClass{public:TestClasS(){cout<<"Hello"<<endl;WriteFile("Hello");}~TestClasS(){cout<<"Test"<<endl;WriteFile("Test");}};void main(){ClearFile();try{//********2********throw1;}catch(int){cout<<"出现异常情况"<<endl;WriteFile("出现异常情况");}}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2,此工程中含有一个源程序文件proj2.cpp,其中定义了Sort类和InsertSort类。Sort是一个表示排序算法的抽象类,成员函数mySort为各种排序算法定义了统一的接口,成员函数swap实现了两个整数的交换操作。InsertSort是Sort的派生类,它重新定义了基类中的成员函数mySort,具体实现了简单插入排序法。本程序的正确输出结果应为: Before sorting a[]= 5,1,7,3,1,6,9,4,2,8,6, After sorting a[]= 1,1,2,3,4,5,6,6,7,8,9, 请首先阅读程序,分析输出结果,然后根据以下要求在横线处填写适当的代码并删除横线,以实现上述功能。 (1)将Sort类的成员函数swap补充完整,实现两个整数的交换操作; (2)将InsertSort类的构造函数补充完整; (3)将InsertSort类的成员函数mySort补充完整,实现简单插入排序法(在交换数据时,请使用基类的成员函数swap)。 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found ****”。 //proj2.cpp #include <iostream> using namespace std; class Sort { public: Sort (int* a0, int n0): a (a0), n(n0) {} virtual void mySort() = 0; static swap(int //********** found********** ______; y = tmp; } protected: int* a; int n; }; class InsertSort : public Sort { public: InsertSort(int* a0, int n0) //********** found********** :______ { } virtual void mySort() { for(int i =1; i<n; ++i) for(int j = i; j>0; --j) if(a[j] <a[j-i]) //********** found********** ______; else //********** found********** ______; } }; void fun (Sort} void print (int * a, int n) { for(int i = 0; i<n; ++i) cout << a[i] << ","; cout << endl; } int main(int argc, char * argv[]) { int a[] ={5, 1, 7, 3, 1, 6, 9, 4, 2, 8, 6}; cout << "Before sorting a[] = /n"; print(a, 11); InsertSort bs(a, 11); fun(bs); cout << "After sorting a[] = /n"; print(a, ii); return 0; }
进入题库练习
问答题使用VC6打开源程序文件modi3.cpp。此程序的功能是将out1.txt文件中的内容输出到屏幕与文件中。输出如下: 李一 1.78m 21 王一 1.65m 23 out2.txt文件的内容如下: 李一 1.78m 21 王一 1.65m 23 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)以输入方式打开文件out1.txt,请在注释//********1********后添加适当的语句。 (2)以输出方式打开文件out2.txt,请在注释/********2********后添加适当的语句。 (3)从文件中获得一个字符,判断是否结束,如果结束则退出输出。 请在注释//********3********后添加适当的语句。 (4)把获得的字符输出到文件中,请在注释//********4********后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>#include<fstream.h>#include<stdlib.h>void main(){ char ch; fstream infile,outfile; //********1******** infile.open("out1.txt"); if(!infile) {cout<<"out1.txt文件不能打开"<<endl; abort(); } //********2******** outfile.open("out2.txt"); if(!outfile) { cout<<"out2.txt文件不能打开"<<endl; abort(); } //********3******** while() { cout<<ch; //********4******** } cout<<endl; infile.close(); outfile.Close();}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 5 1 注意:错误的语句在∥********error********的下面,修改该语句即可。 #include ∥********error******** enum { Sun, Mon, Tue, Wed, Thu, Fri, Sat, ∥********error******** }MyEnum; struct Struct { ∥********error******** int Fri, int Sun; }; void main() { int i=Mon; MyEnum t=Fri; Struct str1; Strl.Fri=Mon; cout<
进入题库练习
问答题使用VC6打开考生文件夹下的工程test35_3。此工程包含一个test35_3.cpp,其中定义了时钟类clock,但该类的定义并不完整。请按要求完成下列操作,将程序补充完整。 (1)定义类clock的私有数据成员hour和minute,它们都是int型的数据。请在注释“//**1**”之后添加适当的语句。 (2)补充完全类clock的构造函数,私有数据成员hour和minute分别初始化为参数h和m的值,请在注释“//**2**”之后添加适当的语句。 (3)完成类clock的成员函数printtime,的定义,该函数以“Now the time is hour:minute”的格式输出数据成员hour和 minute的值,如hour=3、minute=59,则输出为“Now the time is 03:59”,请在注释“//**3**”之后添加适当的语句。 (4)完成类clock的成员函数addoneminutetime的定义,该函数可将clock类对象表示的时间加一分钟,如现在hour=3、 minute=59,运行该函数后hour=4、minute=0。请在注释“//**4**”之后添加适当的语句。 程序的输出结果如下: Now,the time is 12:59 Now,the time is 13:00 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 源程序文件test35_3.cpp清单如下: #include<iostream.h> class clock private: // ** 1 ** public: clock(int h, int m) // ** 2 ** int presenthour()return hour; int presentminute()return minute; void addoneminutetime(); void printtime(); ; void clock::printtime() if(hour<10) cout<<'0'; // ** 3 ** if(minute<10) cout<<'0'; cout<<minute<<end1; void clock::addoneminutetime() // ** 4 ** if(minute>59) minute-=60; hour++; if(hour>23) hour=0; void main ( ) clock c(12,59); c.printtime(); c.addoneminutetime(); c.printtime();
进入题库练习
问答题使用VC6打开 下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使该程序的输出结果为: 20,15 15,20 注意:错误的语句在//******error******的下面,修改该语句即可。 #include<iostream.h> //******error****** void Exchange1(int m, int n) { int t=m; m=n; n=t; } //******error****** void Exchange2(int m, int n) { int t=*m; *m=*n; *n=t; } void main() { int b=20; int a=15; Exchange1(a,b); cout a "," b endl; //******error****** Exchange2(a,b); cout a "," b endl; }
进入题库练习
问答题使用VC6打开下的源程序文件modi3.cpp,其中定义了用于表示日期的类Date,但类Date的定义并不完整,按要求完成下列操作,将类的定义补充完整。(1)定义私有成员变量year、month、day,分别表示年、月、日,类型为int。请在注释//********1********后添加适当的语句。(2)完成构造函数,分别给year、month、day赋值,请在注释//********2********后添加适当的语句。(3)完成重载符号“+=”的定义,请在注释//********3********后添加适当的语句。(4)完成print()打印函数,如2008年8月8日到屏幕和文件modi3.txt格式相同,请在注释//********4********后添加适当的语句。注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>#include<fstream>#include<iomanip>#include<cmath>usingnamespacestd;voidWriteFile(intc){ofstreamout1;out1.open("modi3.txt",ios_base::app);out1.close();}voidWriteFile(char*str){ofstreamout1;out1.open("modi3.txt",ios_base::app);out1str;out1.close();}voidClearFile(){ofstreamout1;out1.open("modi3.txt");out1.close();}classDate{public:Date(inty,intm,intd){//********2********}voidprint()const;//********3********{month+=m;inti=month/12;intj=month%12;if(j==0){year+=(i-1);month=12;}else{year+=i;month=j;}return*this;}private://********1********};voidDate::print()const{//********4********WriteFile(year);WriteFile("年");WriteFile(month);WriteFile("月");WriteFile(day);WriteFile("日");}intmain(){ClearFile();DateOly_day(2008,8,8);Oly_day+=3;Oly_day.print();return0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成列操作,将类的定义补充完整,实现以下功能: (1)完成CBook类构造函数,对整型变量ID和作者Author进行赋值,请在注释∥********1********后添加适当的语句。 (2)完成类CBooks的析构函数,释放申请的内存,请在注释∥********2********后添加适当的语句。 (3)完成类CBooks的AddBookMember函数,请在注释∥********3********后添加适当的语句。 (4)完成CBooks类,用于由书的ID检索到作者的函数char*GetBookAuthor(int hiD),请在注释∥********4********后添加适当的语句。 (5)程序的输出结果为: Tom Harry 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include #include class CBook { public: int ID; char Author[32]; public: CBook(int ID—Number,char* Author_Name) { thiS一>ID:ID_umber; ∥********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 ; delete m_pBook 一>book; delete m_pBook; m_pBook=P ; } } int AddBookMenber(int nID,char*Author) { Node*P=m_pBook; Node*q=NULL; ∥********3******** while() { if(nID==P一> book一>ID) { return 0, } q=P ; P=P一>next ; } if(P==NULL) { P=new Node, P一>next=NULL, P一>book =new CBook(nID,Author); } if(q==NULL) { m_pBook=p; } else { q一>next=P; } return 1 ; } char*GetBookAuthor (int nID) { Node*P=m pBook; ∥********4******** while() { if(p一>book一>ID ==nID) { return P一> book->Author ; } P=p一>next; } return 0 ; }; int main() { CBooks booksl ; books 1.AddBookMenbe r (1,“Tom”); booksl.AddBookMenber (3,“Lee”); books 1.AddBookMenbe r (4,“Lily”); books 1.AddBookMenber (5,“Harry”); cout<
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp,其中定义了用于表示矩形的CRect类,但类CRect的定义并不完整。请按要求完成下列操作,将类CRect的定义补充完成。 (1)定义私有数据成员leftPoint、topPoint、rightPoint、bottomPoint,分别用于表示矩形左上角及右下角的点的坐标,它们都是double型的数据。请在注释//********1********之后添加适当的语句。 (2)完成默认构造函数CRect的定义,指定缺省实参为0,都是double型的数据。请在注释//********2********之后添加适当的语句。 (3)定义函数体为空的析构函数。请在注释//********3********之后添加适当的语句。 (4)在main()函数中定义CRect类的实例rect2,并把rect1的值赋给rect2。请在注释//********4********之后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include <iostream.h> class CRect { private: //********1******** public: //********2******** //********3******** void SetPoints(double, double, double, double); void SetLeftPoint(double m) {leftPoint=m;} void SetRightPoint(double m) {rightPoint=m;} void SetTopPoint(double m) {topPoint=m;} void SetBottomPoint (double m) {bottomPoint=m;} void Display(); }; CRect::CRect(double 1, doublet, double r, double b) { leftPoint=l; topPoint=t; rightPoint=r; bottomPoint=b; } void CRect::SetPoints(doublel, double t, double r, double b) { leftPoint=l; topPoint=t; rightPoint=r; bottomPoint=b; } void CRect::Display() { cout "left-top point is (" leftPoint "," topPoint ") " "/n"; cout "right-bottom point is (" right Point ", " bottomPoint ")" "/n"; } void main(){ CRect rect0; rect0.Display(); rect0.SetPoints(20,20.6,30,40); rect0.Display(); CRect rectl(0,0,150,150); rect1.SetTopPoint(10.5); rect1.SetLeftPoint(10.5); //********4******** rect2.Display(); }
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。请完成函数fun(cbar *str,char ch)的定义,本函数采用二分法,在已按字母次序从小到大排序的字符数组str中,查找字符ch,若ch在数组中,函数返回字符ch在数组中的下标,否则返回1。 二分法查找的思想是初始查找区间的下界为0,上界为len-1,查找区间的中部后,k=(下界+上界)/2;若list[k]等于ch,查找成功;若list[k])ch,则新的查找区间的下界不变,上界改为k-1;否则新的查找区间的下界改为k+1,上界不变。在新区间内继续用二分法查找。 注意:请勿改动主函数main与其他函数中的任何内容,仅在函数fun的花括号中填入所编写的若干语句。 试题程序: #inclLlde<iostream.h> int fun(char *str,chat ch) void main() char str[]='a','b','c','d','e','f','g','h','i','j','k'; char ch; cout<<"请输入一个字符:"<<end1; cin>>ch; cout<<"输入字符的位置是:"<<fun(str,ch)<<end1; return;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。完成函数ToUpper(char*des.char*str),该函数实现把str字符串中小写字符转换成大写字符,并存发在des中。 例如:str=“aBcdrFGHijK”: 则:des=“ABCDEFGHIJK”: 注意:不能修改程序的其他部分,只能补充ToUpper()函数。 #include #define MAXLEN 1024 void ToUpper(char*des,char*str) { } void main() { char deSt[MAXLEN]; char*str=“aBcdrFGHi JK”: ToUpper(dest,Str); cout<
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1,此工程中包含程序文件main.cpp,其中有ElectricFan(“电风扇”)类和主函数main的定义。程序中位于每个“// ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 品牌:清风牌,电源:关,风速:0 品牌:清风牌,电源:开,风速:3 品牌:清风牌,电源:关,风速:0 注意:只修改每个“// ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> using namespace std; class ElectricFan { //“电扇”类 char * brand; int intensity; //风速:0-关机,1-弱,2-中,3-强 public: ElectricFan(const char * the_brand): intensity(0) { brand = new char[strlen (the_brand) +1]; strcpy(brand, the brand); } ~ElectricFan() {delete[] brand;} // ERROR *******found******* const char * theBrand() const {return * brand;} //返回电扇品牌 int theIntensity() const {return intensity;} //返回风速 bool isOn() const {return intensity>0;} //返回电源开关状态 // ERROR *******found******* void turnOff() {intensity=1;} //关电扇 void setIntensity (int inten) { //开电扇并设置风速 // ERROR *******found******* if (intensity >= 1 } void show() { cout << "品牌:" << theBrand() << "牌" << ",电源:" << (isOn())? "开":"关") << ",风速:" << theIntensity() << endl; } }; int main() { ElectricFan fan ("清风"); fan.show(); fan.setIntensity(3); fan.show(); fan.turnOff(); fan.show(); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.cpp,但该程序运行时有错,请改正程序中的错误,使该程序的输出结果为: 100 注意:错误的语句在//********error********的下面,修改该语句即可。#include<iostream.h>static int x=50;int t=0;int*func(int x,int y,int z){ t=t+x+y+z; //********error******** return t;};Void main(){ int y=30; int x=10; int z=20; //********error******** x=x; //********error******** cout<<func(x,y,z)<<endl;}
进入题库练习
问答题编写类AA的成员函数int Compare(AAb), 该函数用于比较*this与b的大小,若两者含有元素的个数n相同,并且数组中前n个元素值对应相同,则认为两者相等返回1,否则返回0。注意:用数组方式及for循环来实现该函数。输出结果如下: a=b a<>C 注意:部分源程序已存在文件testl7_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数Compare的花括号中填写若干语句。 文件testl7_2.cpp的内容如下: #include<iostream.h> #include<stdlib.h> class AA int *a; int n; int MS; public: void InitAA(int aa[], int nn, int ms) if(nn>ms) cout<<"Error!"<<end1; exit(1); MS=ms; n=nn; a=new int[MS]; for(int i=0; i<n; i++) a[i]=aa[i]; int Compare(AA b); ; int AA::Compare(AA b) void main() AA a,b,c; int x[]=1,2,3,4,5; int y[]=1,2,3,6,7; int z[]=1,2,5,7,9;a. InitAA(x,3,5);b. InitAA(y,3,5);c. InitAA(z,3,5); if (a.Compare(b)) cout<<"a=b"<<end1; else cout<<"a<>b"<<end1; if (a.Compare(c)) cout<<"a=c"<<end1; else cout<<"a<>c"<<end1;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义复数类CComplex的私有成员变量real和imaginary,分别用来表示复数的实部和虚部,都是double 类型的变量。请在注释//********1********后添加适当的语句。 (2)添加复数类CComplex的带一个参数的构造函数,分别将real和imaginary赋值为参数r和0。请在注释//********2********后添加适当的语句。 (3)完成对运算符“+”的重载,分别对复数的实部和虚部相加。请在注释//********3********后添加适当的语句。 (4)完成复数的友元函数Equal(CComplex&c1,CComplex&c2)的定义,如果两个数的实部和虚部都相等,则返回1,否则返回0,请在注释//********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>class CComplex{private: //********1********public: CComplex() { real:imaginary=0; ) CComplex(double r) { //********2******** } CComplex operator+(CComplex&c1) { //********3******** temp.real=real+c1.real; temp.imaginary:imaginary+c1.imaginary; return temp; } void Set(int re,int imag) { real=re; imaginary=imag; } friend bool Equal(CComplex&c1,CComplex&c2);}; bool Equal(CComplex&c1,CComplex&c2){ //********4******** } int main() { CComplex complexl(5); CComplex complex2; cout<<Equal(complexl,comp lex2)<<endl; complex2.Set(5,0); cout<<Equal(complexl,comp lex2)<<endl; return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中包含了类Integers和主函数main的定义。一个Integers对象就是一个整数的集合,其中包含0个或多个可重复的整数。成员函数add的作用是将一个元素添加到集合中,成员函数remove的作用是从集合中删除指定的元素(如果集合中存在该元素),成员函数sort的作用是将集合中的整数按升序进行排序。请编写这个sort函数。此程序的正确输出结果应为: 5 28 2 4 5 3 2 75 27 66 31 5 28 2 4 5 3 2 75 27 66 31 6 5 28 2 4 5 3 2 75 27 66 31 6 19 5 28 4 5 3 2 75 27 66 31 6 19 5 28 4 5 3 2 75 27 66 31 6 19 4 2 3 4 4 5 5 6 19 27 28 31 66 75 要求: 补充编制的内容写在“//******333******”与“//******666******”之间。不得修改程序的其他部分。 注意:相关文件包括:main.cpp、Integers.h。 程序最后调用writeToFile函数,使用另一组不同的测试数据,将不同的运行结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件。 //Integers.h #ifndef INTEGERS #define INTEGERS #include<iostream> using namespace std; const int MAXELEMENTS=100; //集合最多可拥有的元素个数 class Integers{ int elem[MAXELEMENTS]; //用于存放集合元素的数组 int counter; //用于记录集合中元素个数的计数器 public: Integers(): counter(0){} //创建一个空集合 Integers(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 sort(); //将集合中的整数按由小到大的次序进行排序 void show()const; //显示集合中的全部元素 }; void writeToFile(const char*path); #endif //main.cpp #include"Integers.h" #include<iomanip> Integers::Integers(int data[], int size): counter(0){ for(int i=0; i<size; i++) add(data[i]); } void Integers::add(int element){ if(counter<MAXELEMENTS) elem[counter++]=element; } void Integers::remove(int element){ int j; for(j=counter-1; j>=0; j--) if(elem[j]==element)break; for(int i=j; i<counter-1; i++) elem[i]=elem[i+1]; counter--; } void Integers::sort(){ //******333****** //******666****** } void Integers::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); Integers 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(); s.sort(); s.show(); writeToFile(""); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数IsPalindromes(cha*string)实现的功能是判定给定的字符串是否构成回文字符串,如果是则返回1,否则返回0。 如:1234554321或者1234321都认为是回文字符串。 如果串为空或一个字母时,均认为是回文字符串。 注意:不能修改程序的其他部分,只能补充 IsPalindromes()函数。 #include #define MAXLEN 1 02 4 bool IsPalindromes(char*string) { } void main() { char str[MAXLEN]; cout<<“请输入一行文字"<
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。请完成以下函数: int factorial(int n):求出n的阶乘,必须使用递归调用。 如果n小于1则返回0。 注意:不能修改函数的其他部分。 #include #include int factorial(int n) { } void main() { cout<
进入题库练习