计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码。函数show()的功能是将1、2、3、4四个数字,组成互不相同且无重复数字的四位数,并将这些数输出到屏幕,输出的内容如下: 1234 1243 1324 1342 1423 1432 2134 2143 2314 2341 2413 2431 3124 3142 3214 3241 3412 3421 4123 4132 4213 4231 4312 4321 将函数show()补充完整。 注意:请勿改动主函数。 #include void show() { } int main() { show(); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数factor(int*des,int&length,int n)实现的功能是:将n所有因数存放到des中,通过length引用返回因数的个数,比如fator(a,length,20)执行后,则a={1,2,4,5,10,20},length=6。 注意:只能补充函数factor 0,请勿改动其他部分的内容。 #include #define MAXNLEN 100 void factor(int*des,int&length, int n) { } void main() { int a[MAXNLEN],length; int n=20; factor(a,length,n); for(int i=0;i
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,阅读下列程序说明和代码,功能如下: 从屏幕输入数字,然后由大到小插入指定的链中。当输入0时,表示输出的数据已经输入完成,然后把数据打印到屏幕,然后释放内存。 其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。 (1)在父节点的Next中保存新插入的节点的指针,请在注释//********1********后添加适当的语句。 (2)把pNext的子节点赋给pNext本身,请在注释//********2********后添加适当的语句。 (3)判定P的子节点不为空,如果不为空,则打印P其中的数据到屏幕,请在注释//********3********后添加适当的语句。 (4)用tempi保存动态申请内存节点的链表头,请在注释//********4********后添加适当的语句。 注意:仅在函数指定位置添加语句,请勿改动主函数main与其他函数中的任何内容。#include<iostream.h>Class TestClass{public: TestClass(int data=0) { This->data=data; This->next=NULL; }; int data; TestClass* next;};void Insert(TestClass*p,int data){ TestClass*temp=new TestClass(data); TestClass*pParent=p; TestClass*pNext=p一>next; while(pNext) { if(data>pNext一>data) { //********1******** temp一>next=pNext; return; } Else { pParent=pNext; //********2******** } } if(pNext==NULL) { pParent一>next=temp; return; }}void printf(TestClass*p){//********3******** while() { cout<<p一>next一>data<<" "; p=p一>next ; } cout<<endl;}void Delete(TestClass*p){ //********4******** TestClass*temp1=; TestClass*temp2; while(temp1!=NULL) { temp2=temp1->next; delete temp1; templ=temp2; }}void main(){ int i=0; TestClass head; do { int data; cout<<"请输入一个数字:"<<endl; cin>>data; if(data==0)break; Insert(&head,data); }while(1); printf(&head); Delete(&head); return; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,补充空出的代码。函数convert(char*des,char*str)的功能是去掉字符串str中相同的字母,并将处理后的结果存到des所指的字符串中。例如:输入:This is great!输出:This grea!注:卷:不能修改程序的其他部分,只能补充fun()函数。#include<iostream.h>#define MAXLEN1024void convert(char*des,char*str){}void main(){char sour[MAXLEN];char dest[MAXLEN];cout<<"Pleaseinput a string:"<<endl:cin.getline(sour,MAXLEN);convert(dest,sour);cout<<dest<<endl;return;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,该工程中包含程序文件main.cpp,其中有类Door(“门”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: 打开503号门…门是锁着的,打不开。 打开503号门的锁…锁开了。 打开503号门…门打开了。 打开503号门…门是开着的,无须再开门。 锁上503号门…先关门…门锁上了。 注意:只修改每个“//ERROR**********found**********”下的那一行,不要改动程序中的其他内容。#include<iostream>using namespace std;class Door{ int num; //门号 bool closed; //true表示门关着 bool locked; //true表示门锁着public: Door(int num){//ERROR*********found********* num=thiS->num; closed=locked=true; } bool isClosed()const{ returnclosed;}//门关着时返回true,否则返回false bool isOpened()const{return!closed;)//门开着时返回true,否则返回false bool iSLocked()const{ returnlocked;)//门锁着时返回true,否则返回false bool isUnlocked()conSt{return ! locked;)//门未锁时返回true,否则返回false void open(){ //开门 cout<<end1<<”打开”<<num<<”号门…”; //ERROR*********found********* if(closed) cout<<”门是开着的,无须再开门。”; else if(locked) cout<<”门是锁着的,打不开。”; else{ Closed=false; cout<<“门打开了。”; } } void close(){ //关门 cout<<endl<<”关上”<<num<<”号门…”; if(closed) cout<<”门是关着的,无须再关门。”; else{ closed=true; cout<<“门关上了。”; }}//ERROR*********found********* void lock()const{ //锁门 cout<<endl<<“锁上”<<num<<”号门…”; if(locked) cout<<“门是锁着的,无须再锁门。”; eise{ if(!closed){ cout<<”先关门…”; closed=true; } locked=true; cout<<”门锁上了。”; } } void unlock(){ //开锁 cout<<endl<<”开”<<num<<”号门的锁…”; if(!locked) cout<<“门没有上锁,无须再开锁。”; eise { locked=false;cout<<”锁开了。”; } } }; int main(){ Door door(503); door.open(); door.unlock(); door.open(); door.open(); door.lock(), return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)类CBase有一个常数变量Number1,在构造函数时对其初始化,请在注释//********1********后添加适当的语句。 (2)类CPri是CBase的公共继承类,请在注释//********2********后添加适当的语句。 (3)类CPri构造函数有两个形式参数,第一个是对CBase的初始化,第二个缺省为0,用来对变量Number2进行初始化。请在注释//********3********后添加适当的语句。 (4)类CPri的函数display()重载于CBase的打印函数。完成对变量Number2的输出,然后调用基类的打印函数,请在注释//********4********后添加适当的语句。输出的内容如下: Number2=12 Number=8 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。#include<iostream.h>Class CBase{private: int Number;public: //********1******** CBase(int x) {} void display() { cout<<"Number="<<Number<<end1; }};//********2********class CPri{private: int Number2;public: //********3******** CPri(int x,int y=0) { Number2=y; ) void display() { //********4******** }};int main(){ CPri obj(8,12); obj.display(); return 0;}
进入题库练习
问答题使用VC++ 6.0打开 下的源程序文件1.cpp,该程序运行时有错,请改正其中的错误,使程序正确运行,并且使程序输出的结果为: Hello Visual C++! Hello Visual C++!! 注意:错误的语句在//******error******的下面,修改该语句即可。 试题程序: #include<iostream.h> class CMyObject { public: CMyObject() { //******error****** cout<<"Hello, "Visual C++!"<<endl; } CMyObject(int n) { //******error****** cout<<"Hello,/n Visual C++!!"<<endl; } //******error****** ^CMyObject() { } }; void main() { CMyObject obj1; CMyObject obj2(0); }
进入题库练习
问答题请编写一个函数void fun(int p[],int n,int c),其中数组p的元素按由小到大的顺序排列,其元素个数为n。函数fun()的功能是将c插入到数组p中,且保持数组的升序排列。 注意:部分源程序已存在文件PROC9.cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句; 文件PROC9.cpp的内容如下: //PROC9.cpp #include <iostream> #include <string> using namespace std; #define M 30 void fun(int p[ ],int n,int c); int main () int pp[M],n,i; int fg, c; cout<<"Please input n:/n"; cin>>n; cout<<"Please input the n data:/n"; for (i=0; i<n; i++) cin>>pp [i]; cout<<"Please input c:/n"; cin>>c; fun (pp, n, c); for (i=0; i<n; i++) cout<<pp [i] << " " ; cout<<end1; return 0; void fun(int p[ ],int n, int c) //* * * * * * * * *
进入题库练习
问答题*
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹prog1下的工程prog1,该工程中包含程序文件main.cpp,其中有Salary(“工资”)类和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句行有错误,请加以改正。改正后程序的输出结果应为:应发合计:3500应扣合计:67.5实发工资:3432.5注意:只修改每个“//ERROR****found****”下的那一行,不要改动程序中的其他内容。#include<iostream>usingnamespacestd;classSalary{public:Salary(constchar*id,doublethe_base,doublethebonus,doublethe_tax)//ERROR**********found**********:thebase(base),thebonus(bonus),thetax(tax){staffid=newchar[strlen(id)+1];strcpy(staffid,id);}//ERROR**********found**********~Salary(){delete*staffid;)doublegetGrossPay()const{returnbase+bonus;}//返回应发项合计doublegetNetPay()const{returngetGrossPay()_tax;}//返回实发工资额private:char*staffid;//职工号doublebase;//基本工资doublebonus;//奖金doubletax;//代扣个人所得税};intmain(){Salarypay("888888",3000.0,500.0,67.50);cout<<"应发合计:"<<pay.getGrossPay()<<"";cout<<"应扣合计:"<<pay.getGrossPay()-pay.getNetPay()<<"";//ERROR**********found**********cout<<"实发工资:"<<pay::getNetPay()<<end1;return0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程proj3,其中使用友元函数访问类的私有数据成员,求出两个数据成员的大于1的最小公因子。请编写友员函数FriFun,使其输出结果为:rnmmondenominatoris2要求:补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。//proj3.hclassFriFunClass{inta,b;public:FriFunClass(inti,intj){a=i;b=j;)friendintFriFun(FriFunClasSX);//友元函数};voidwriteToFile(constchar*);//proj3.cpp#include<iostream>usingnamespacestd;#include"prj3.h"intFriFun(FriFunClassx){//********333********//由于函数FriFun()是类FriFunClass的友元函数。所以它可以直接访问a和b//********666********}intmain(){FriFunClassn(10,20);if(FriFun(n))cout<<"Commondenominatoris"<<FriFun(n)<<"\n";elsecout<<"NOcommondenominator.\n";writeToFile("");return0;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj2下的工程proj2。其中的Collection定义了集合类的操作接口。一个集合对象可以包含若干元素。工程中声明的Array是一个表示整型数组的类,是Collection的派生类,它实现了Collection中声明的纯虚函数。Array的成员说明如下: 成员函数add用于向数组的末尾添加一个元素; 成员函数get用于获取数组中指定位置的元素; 数据成员a表示实际用于存储数据的整型数组; 数据成员size表示数组的容量,数组中的元素个数最多不能超过size; 数据成员num表示当前数组中的元素个数。 请在横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为: 1,2,3,4,5,6,7,8,9,10, 注意:只在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。 #include <iostream> using namespace std; //集合类的操作接口 class Collection { public: virtual void add (int e) = 0; //获取指定位置的元素 virtual int get (unsigned int i) const = 0; }; //实现了集合接口 class Array : public Collection { public: Array (unsigned int s) { //********** found********** a = new ______; size = s; num: 0; } ~Array ( ) { //********** found********** ______: } virtual void add (int e) { if (num< size) { //********** found********** ______=e; num ++; } } virtual int get ( unsigned int i) const { if (i < size) { //********** found********** ______; } return 0; } private: int * a; unsigned int size; unsigned int hum; }; void fun (Collection for (i = 0; i < 10; i++) { col.add (i+1); } for (i = 0; i<10; i++) { cout << col.get(i) << ","; } cout << endl; } int main () { Array a (0xff); fun (a); return 0; }
进入题库练习
问答题使用VC6打开 下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)定义CMyTime的私有成员函数m_year、m_month类型为int,请在注释//********1********后添加适当的语句。 (2)补充完成CMyTime的构造函数,完成对m_year、m_month的赋值,请在注释//********2********后添加适当的语句。 (3)完成print()的输出,请在注释//********3********后添加适当的语句。输出格式如下: Current Time year.xx month:xx 注意:xx表示两位0-9的数字,如Current Time year:08 month:04。 (4)完成对month的增加函数AddMonth(int m),请在注释//********4********后添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include<iostream.h> class CMyTime { private: //********1******** public: CMyTime(int year, int month) { //********2******** } void display() { char yearChar[3]; char monthChar[3]; yearChar[0]=(m_year%100)/10 +"0"; yearChar[1]= (m_year%10)+"0"; monthChar[0]=(m_month%100)/10+"0"; monthChar[1]=(m_month%10)+"0"; //********3******** cout "Current Time" " year: " yearChar " month:" monthChar endl; } void AddMonth(int m) { m_month =m_month-1+m; //********4******** m_month=m_month %12+1; } void AddYear(int n) { m_year=m_year+n; } }; int main() { CMyTime myTime(2006,11); myTime.AddMonth(5); myTime.display(); myTime.AddYear(1); myTime.display(); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj1下的工程proj1,此工程中包含源程序文件main.cpp,其中有类Book(“书”)和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句行有错误,请加以改正。改正后程序的输出结果应该是:书名:C++语言程序设计总页数:299已把“C++语言程序设计”翻到第50页已把“C++语言程序设计”翻到第51页已把书合上。书是合上的。已把“C++语言程序设计”翻到第1页注意:只修改每个“//ERROR****found****”下的一行,不要改动程序中的其他内容。#include<iostream>usingnamespacestd;classBook{char*title;intnum_pages;//页数intcur_page;//当前打开页面的页码,0表示书未打开public:Book(constchar*theTitle,intpages):num_pages(pages){//ERROR**********found**********title=newchar[strlen(theTitle)];strcpy(title,theTitle);cout<<end1<<"书名:"<<title<<"总页数:"<<num_pages;}~Book(){delete[]title;}//ERROR**********found**********boolisOpen()const{returnnum_pages!=0;)//书打开时返回true,否则返回falseintnumOfPages()const{returnnum_pages;)//返回书的页数intcurrentPage()const{returncurpage;}//返回打开页面的页码voidopenAtPage(intpage_no){//把书翻到指定页cout<<end1;if(page_no<1||page_no>num_pages){cout<<"无法翻到第"<<cur_page<<"页。";close(); }else {cur_page=page_no;cout<<"已把“"<<title<<"”翻到第"<<cur_page<<"页"; }}voidopenAtPreVPage(){openAtPage(cur_page一1);)//把书翻到上一页voidopenAtNextPage(){openAtPage(cur_page+1);)//把书翻到下一页voidclose(){//把书合上cout<<end1;if(!isOpen())cout<<"书是合上的。";else{//ERROR**********found**********num_pages=0;cout<<"已把书合上。";}cout<<end1; }};intmain(){Bookbook("C++语言程序设计",299);book.openAtPage(50);book.openAtNextPage();book.close();book.close();book.openAtNextPage();return0;}
进入题库练习
问答题使用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=5 area=78.54 height=10 vol=785.4 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>const double pi=3.1416;Class circle{protected: //********1********public: //********2******** { r=0.0; } circle(double radius) { r=radius; } Void print() { area=r*r*pi; cout<<"radius="<<r<<''<<"area="<<area<<endl; } }; class column:protected circle { protected: double h;public: //********3******** { h=height; r=radius; } Void print() { Circle::print(); //********4******** }};int main(){ column col(5.0,10.0); col.print(); return 0;}
进入题库练习
问答题使用VC++6.0打开 下的源程序文件1.cpp,使它能运行正确的结果。 注意:不要改动其他语句,不得增行或删行,也不得更改程序的结构! 本程序要求屏幕输出:i=12345 注意:语句在/********error********/的下面。修改该语句即可,其他的语句不能修改。 试题程序: #include<iostream.h> /********error********/ class TC() { public: /********error********/ void~TC(){} TC(int i) { cout<<"i"<<"="<<i<<endl; } /********error********/ } void main() { TC obj(12345); return; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中使用友元函数访问类的私有数据成员,求出两个数据成员的大于1的最小公因子。请编写友员函数FriFun,使其输出结果为: Common denominator is 2 要求:补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。 //proj3.h class FriFunClass { int a, b; public: FriFunClass(int i, int j) { a=i; b=j;} friend int FriFun (FriFunClass x); //友元函数 }; void writeToFile(const char *); //proj3.cpp #include <iostream> using namespace std; #include "prj3.h" int FriFun (FriFunClass x) { //******** 333******** //由于函数FriFun()是类FriFunClass //******** 666******** } int main ( ) { FriFunClass n(10, 20); if (FriFun (n)) cout <<"Common denominator is "<<FriFun(n)<<"/n"; else cout <<"No common denominator./n"; writeToFile(""); return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: 1 0 注意:错误的语句在∥********error********的下面,修改该语句即可。 #include struct Struct { union { int a; char C[4]; }; int b ; ∥********error******** } void msin() { 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<
进入题库练习
问答题请使用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> using namespace std; class Date{ //日期类 int year,month,day;//年、月、日 public: Date(int year,int month,int day):year(year),month(month),day(day){} int getYear()const{return year;} int getMonth()const{return month;} int getDay()const{return day;} }; class Person{ //人员类 char name[14];//姓名 bool is_male;//性别,为true时表示男性 Date birth_date;//出生日期 public: Person(char*name,bool is_male,Date birth_date) //**********found********** :__________ { strcpy(this->name,name); } const char*getName()const{return name;} bool isMale()const{return is_male;} Date getBirthdate()const{return birth_date;} //利用strcmp()函数比较姓名,返回一个正数、0或负数,分别表示大于、等于、小于 int compareName(const Person&p)const{ //**********found********** __________ } void show(){ tout<<endl: cout<<name<<''<<(is_male?"男":"女")<<''<<"出生日期:"<<birth_date.getYear()<<"年"//显示出生年 //**********found********** //显示出生月 <<birth_date.getDay()<<"日";//显示出生日 } }; void sortByName(Person ps[],int size){ //将人员数组按姓名排列为升序 for(int i=0;i<size-1;i++){ //采用选择排序算法 int m=i; for(int j=i+1;j<size;j++) if(psij].compareName(ps[m])<0) m=j; if(m>i){ Person p=ps[m]; ps [m]=ps[1]; ps[i]=p; } } } int main(){ Person staff[]={ Person("张三",true,Date(1978,4,20)), Person("王五",false,Date(1965,8,3)), Person("杨六",false,Date(1965,9,5)), Person("李四",true,Date(1973,5,30)) }; const int size=sizeof(staff)/sizeof(staff[0]); int i; cout<<endl<<"按姓名排序"; cout<<endl<<"排序前:"; for(i=0;i<size;i++)staff[i].show(); sortByName(staff,size); cout<<endl<<endl<<"排序后:"; for(i=0;i<size;i++)staff[i].show(); cout<<endl: return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp,要求编写一个CMyShape类,含有求面积求周长等纯虚函数。然后编写一个CMyRectangle类和CMyCircle类继承CMyShape,并实现求面积、求周长的两个函数。在main()i~数中测试得到下面的结果: 在CMyShape类构函数造内 在CMyCircle类构造函数内 在CMyShape类构造函数内 在CMyRectangle类构造函数内 myCircle:Area=3 14.1 59 Girth=62.83 19 myRectangle:Area==900 Girth==120 具体要求如下: (1)定义求面积纯虚函数,请在注释∥********1********之处添加适当的语句。 (2)定义求周长纯虚函数,请在注释∥********2********之处添加适当的语句。 (3)请在注释∥********3********和∥********4********之处添加适当的语句。 注意:除在指定位置添加语句之外,请不要改动程序中的其他内容。 #include #include #define PI 3.1415926 clas S CMyPoint { public: int x,y; CMyPoint(int tx,int ty): X(tx),Y(ty)f} }; class CMyShape { public: CMyShape(){coutGetArea() GetGirth()GetArea() GetGirth()<
进入题库练习