计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1,此工程中含有一个源程序文件proj1.cpp。其中位于每个注释“// ERROR **********found**********”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为: NUM=0 Value=1 注意:只修改注释“// ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 // proj1.cpp #include <iostream> using namespace std; class MyClass { int_i; friend void Increment(MyClass public: const int NUM; // ERROR *******found******* MyClass(int i=0) { NUM = 0; _i = i; } int GetValue() const {return _i;} }; // ERROR *******found******* void Increment() {f._i ++;} int main() { MyClass obj; // ERROR *******found******* MyClass::Increment (obj); cout << "NUM = " << obj.NUM << endl << "Value = " << obj.GetValue() << endl; return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1,此工程包含一个源程序文件proj1.cpp。其中位于每个注释“// ERROR ****found****”之后的一行语句存在错误。请改正这些错误,使程序的输出结果为:You are fight. 注意:只修改注释“//ERROR ****found****”的下一行语句,不要改动程序中的其他内容。 // proj1.cpp #include <iostream> using namespace std; class MyClass { public: MyClass(int x):number(x) {} // ERROR *******found******* ~MyClass(int x) {} // ERROR *******found******* void Judge(MyClass private: int number; }; void Judge(MyClass else cout << "Sorry" << endl; } int main() { // ERROR *******found******* MyClass object; Judge(object); return 0; }
进入题库练习
问答题请使用VC6或使用[答题]菜单打开考生文件夹proj3下的工程proj3,其中包含了类IntegerSet和主函数main的定义。一个IntegerSet对象就是一个整数的集合,其中包含0个或多个无重复的整数;为了便于进行集合操作,这些整数按升序存放在成员数组elem的前若干单元中。成员函数add的作用是将一个元素添加到集合中(如果集合中不存在该元素),成员函数remove从集合中删除指定的元素(如果集合中存在该元素)。请编写成员函数remove。在main函数中给出了一组测试数据,此时程序的正确输出结果应为: 2 3 4 5 27 28 31 66 75 2 3 4 5 6 27 28 31 66 75 2 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 3 4 5 6 19 27 28 31 66 75 要求: 补充编制的内容写在“//********333********”与“//********666********”之间,不得修改程序的其他部分。 注意:程序最后将结果输出到文件out.dat中。输出函数WriteToFile已经编译为obj文件,并且在本程序中调用。 //IntegorSet.h #ifndef INTEGERSET #define INTEGERSET #include<iostream> using namespace std; const int MAXELEMENTS=100; //集合最多可拥有的元素个数 class IntegerSet{ int elem[MAXELEMENTS]; //用于存放集合元素的数组 int counter; //用于记录集合中元素个数的计数器 public; IntegerSet(): counter(0){} //创建一个空集合 IntegerSet(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 show () const; }; void WriteToFile(char*); #endif //main.cpp #include"IntegerSet.h" #include<iomanip> IntegerSet::IntegerSet(int data[], int size): counter(0){ for(int i=0; i<size; i++) add(data[i]); } void IntegerSet::add(int element){ int j; //从后往前寻找第一个小于等于element的元素 for(j=counter; j>0; j--) if(element>=elem[j-1])break; //如果找到的是等于element的元素,说明要添加的元素已经存在,直接返回 if(j>0) if(element=elem[j-1])return; //如果找到的是小于element的元素,j就是要添加的位置 //该元素及其后面的元素依次后移,腾出插入位置 for(int k=counter; k>j; k--) elem[k]=elem[k-1]; elem[j]=element; //将element插入到该位置 counter++; //计数器加1 } void IntegerSet::remove ( int element ) { //********333******** //********666******** } void IntegerSet::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}; IntegerSet 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(); WriteToFile (""); return 0; }
进入题库练习
问答题使用VC6打开下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数fun(intn)的功能是在n行n列的矩阵中,每行都有最大的数,本程序求这n个最大数中的最小一个,并作为参数返回。注意:不能修改程序的其他部分,只能修改fun()函数。#include<iostream.h>#defineN100inta[N][N];intfun(intn){}voidmain(){intn;cout"pleaseinputN:"endl;cinn;for(inti=0;i<n;i++)for(intj=0;j<n;j++){cout"pleaseinputaNumber:"endl;cina[i][j];}cout"Theminofmaxnumbersis"fun(n)endl;}
进入题库练习
问答题请编写一个函数sortnum(int num),参数num是一个三位的整数,该函数将num的百位、十位和个位的数字进行重排,并返回由上述的三个数字组成的最大的三位数。 注意:部分源程序已存在文件test28_2.cpp中。 如输入456后,输出结果如下: 654 请勿修改主函数main和其他函数中的任何内容,仅在函数sortnum的花括号中填写若干语句。 文件test28_2.cpp的内容如下: #include<iostream.h> int sortnum(int num) void main() int num; int result=0; cout <<“请输入一个三位数”; cin>>num; cout<<sortnum(num)<<end1;
进入题库练习
问答题使用VC++6.0打开考生文件夹下的源程序文件2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数fun(int n)的功能是实现对一个整数的加密,具体的加密方法是一个4位长的整数,用每位数字加上3然后除以9的余数代替该数字,再将第1位和第4位交换,第2位和第3位交换,然后返回得到的密码。 程序输出结果为 1864 2075 注意:不能修改其他部分的代码。 试题程序: #include<iostream.h> #include<cmath> int fun(int n) int main() int i=1357; cout<<fun(i)<<end1; i=2468; cout<<fun(i)<<end1; return 0;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj1下的工程proj1。程序中位于每个“// ERROR ****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应为: Name:Smith Age:21 ID:99999 CourseNum:12 Record:970 注意:只修改每个“// ERROR ****found****”下的那一行,不要改动程序中的其他内容。 #include <iostream> using namespace std; class StudentInfo { protected: // ERROR *******found******* char Name; int Age; int ID; int CourseNum; float Record; public: StudentInfo(char * name, int Age, int ID, int courseNum, float record); // ERROR *******found******* void ~StudentInfo() {} float AverageRecord() { return Record/CourseNum; } void show() const { cout << "Name:" << Name << "Age:" << Age << "ID:" << ID << "CourseNum:" << CourseNum << "Record:" << Record << endl; } }; // ERROR *******found******* StudentInfo StudentInfo (char * Name, int Age, int ID, int CourseNum, float Record) { Name = name; Age = age; this -> ID = ID; CourseNum = courseNum; Record = record; } int main() { StudentInfo st ("Smith",21,99999,12,970); st.show(); return 0; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程pro.j3,其中包含了类IntegerSet和主函数main的定义。一个IntegerSet对象就是一个整数的集合,其中包含0个或多个无重复的整数;为了便于进行集合操作,这些整数按升序存放在成员数组elem的前若干单元中。成员函数add的作用是将一个元素添加到集合中(如果集合中不存在该元素),成员函数remove从集合中删除指定的元素(如果集合中存在该元素)。请编写成员函数remove。在main函数中给出了一组测试数据,此时程序的正确输出结果应为:23452728316675234562728316675234561927283l667534561927283l66753456192728316675要求:补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。注意:程序最后将结果输出到文件out.dat中。输出函数WriteToFile已经编译为obj文件,并且在本程序中调用。//IntegorSet.h#ifndefINTEGERSET#defineINTEGERSET#include<iOStream>usingnamespacestd;constintMAXELEMENTS=100;//集合最多可拥有的元素个数classIntegerSet{intelem[MAXELEMENTS];//用于存放集合元素的数组intcounter;//用于记录集合中元素个数的计数器public:IntegerSet():counter(0){}//创建一个空集合IntegerSet(intdata[],intsize);//利用数组提供的数据创建一个整数集合voidadd(intelement);//添加一个元素到集合中voidremove(intelement);//删除集合中指定的元素intgetCount()const{returncounter;}//返回集合中元素的个数intgetElement(inti)const{returnelem[i];}//返回集合中指定的元素voidshow()const;},voidWriteToFile(char*);#endif//main.cpp#include"IntegerSet.h"#include<iomanip>IntegerSet::IntegerSet(intdata[],intsize):counter(0){for(inti=0;i<Size;i++)add(data[i]);}voidIntegerSet::add(intelement){intj;//从后往前寻找第一个小于等于element的元素for(j=counter;j>0;j--)if(element>=elem[j-1])break;//如果找到的是等于element的元素,说明要添加的元素已经存在,直接返回if(j>0)if(element=elem[j-1])return;//如果找到的是小于element的元素,j就是要添加的位置//该元素及其后面的元素依次后移,腾出插入位置for(intk=counter;k>j;k--)elem[k]=elem[k-1];elem[j]:element;//将element插入到该位置counter++;//计数器加1}voidIntegerSet::remove(intelement){//********333********//********666********}voidIntegerSet::show()const{for(inti=0;i<getCount();i++)cout<<setw(4)<<getElement(i);cout<<end1;}intmain(){intd[]={5,28,2,4,5,3,2,75,27,66,31);IntegerSetS(d,11);S.show();S.add(6);S.show();S.add(19);S.show();S.remove(2);S.show();S.add(4);S.show();WriteTOFile(””);return0;}
进入题库练习
问答题下列给定程序中,函数fun的功能是:将十进制正整数m转换成k(2≤k≤9)进制数,并按位输出。例如,若输入8和2,则应输出1000(即十进制数8转换成二进制表示是1000)。请改正程序中的错误,使它能得出正确的结果。注意:部分源程序在文件MODI1.C中,不要改动main函数,不得增行或删行,也不得更改程序的结构!试题程序:
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。完成函数fun(char* s,int a[]),其功能是把s中出现的数字转换成数字存储在a[]中,然后返回转换的个数。 例如:s="1234abcdef567"; 则:a[]中存储着1234567 返回:7 注意:不能修改程序的其他部分,只能修改fun()函数。 #include int fun(char* s,int a[]) { } int main() { int a[1024]; int len=fun("1234abcdef567", a); for(int i=0;i
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错,请改正其中的错误,使得程序正常运行,并使程序输出的结果为: sizeof(str1)=5 sizeof(str2)=10 sizeof(str3)=1 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。 (1)不能删除assert()语句; (2)只能修改后面的数字。 提示:assert()函数如果为假,则会产生一个中断异常。#include<iostream.h>#include<assert.h>void main(){ char* str1="abc"; //********error******** assert(sizeof(Str1)==3); cout<<"sizeof(Str1) = 5"<<end1; char str2[10]="ab"; /zsert(sizeof(str2)==2); cout<<"sizeof(Str2)=10"<<end1; char str3=23; //********error******** assert(sizeof(str3)==4); cout<<"sizeof(Str3)=1"<<end1; return;}
进入题库练习
问答题请使用VC6或使用[答题]菜单打开 proj2下的工程proj2,该工程中包含一个程序文件main. epp,其中有日期类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 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(ps [j]. compareName(ps[m])<0) m=j; if(m>i) { Person P=ps[m]; ps[m]: ps[i]; 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或使用[答题]菜单打开考生文件夹proj1下的工程proj1,该工程中包含程序文件main.cpp,其中有类Foo和主函数main的定义。程序中位于每个“//ERROR****found****”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: X=a Y=42 注意:只修改每个“//ERROR*******found*******”下的那一行,不要改动程序中的其他内容。 #include<iostream> using namespace std; class Foo { public: Foo(Char x){x_=x;} char getx()const{return x_;} public: static int y_; private: char x; }; //ERROR********found********* int Foo.y_=42; int main(int argc, char*argv[]) { //ERROR*******found******* Foo f; //ERROR********found********* cout<<"X="<<f.x_<<endl; cout<<"Y="<<f.y_<<endl; return 0; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正错误,使得程序输出: Hello test 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//******error******的下面。 #inc1ude <iostream> //********enror******** temp1ate<T> void fun(T t) { std::cout<<"test"<<std::end1; } //********error******** temp1ate<bool> void fun(bool t) { std::cout<<(t? "Hello": "Hi")<<std::end1; } int main() { //********error******** bool flag= TRUE; fun(flag); fun((int)flag); return 0; }
进入题库练习
问答题请编写一个函数int pattern_index(char substr[],char str[]),该函数执行含通配符“?”的字符串的查找时,该通配符可以与任一个字符匹配成功。当子串substr在str中匹配查找成功时,返回子串substr在str中的位置,否则返回值为0。要求使用 for循环实现。输出结果如下: 子串起始位置:5 注意:部分源程序已存在文件test20_2.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数pattern_index的花括号中填写若干语句。 文件test20_2.cpp的内容如下: #include<iostream.h> int pattern_index(char substr[],char str[]) void main ( ) char *substring,*string; int same; substring="???gram"; string="this program return index of substring"; same=pattern_index(substring, string); if(same) cout<<"子串起始位置: "<<same<<end1; else cout<<"匹配不成功" <<end1;
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi3.cpp。其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。完成以下功能: (1)完成类Rect的构造函数,实现对变量left、right、top、bottom的初始化,缺省值都为0,请在注释//********1********后添加适当的语句。 (2)完成类Rectangle的构造函数,请在注释//********2********后添加适当的语句。 (3)完成计算矩形对角线长度函数Diagonal(),请在注释//********3********后添加适当的语句。 (4)完成计算周长函数Girth(),请在注释//********4********后添加适当的语句。 程序输出: 50 140 注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>#include<cmath>class Rectangle{public: int left , right , top , bottom; //********1******** { left=1; right=r; top=t; bottom=b; } //********2******** { left=rc.1eft; right=rc.right; top=rc.top; bottom=rc.bottom; } float Diagonal() { //********3******** return } int Girth() { //********4******** return }};int main(){ Rectangle rect(20,50,40,80); Rectangle rect2(rect); cout<<rect2.Diagonal()<<endl; cout<<rect2.Girth()<<endl; return 0;}
进入题库练习
问答题使用VC++6.0打开 下的源程序文件3.cpp。其中定义的类不完整,按要求完成下列操作,将类的定义补充完整。 (1)完成构造函数,设置数组元素的个数为0,请在注释1之后添加语句。 (2)完成函数AddMember(int n),如果参数n包含在类的数据成员数组中,则返回0,否则把数据写入数组,然后返回1,请在注释2之后添加语句。 (3)完成函数DelMember(int n),如果变量在数据中,则删除该变量,并且返回1,如果不存在,则返回0,请在注释3之后添加语句。 (4)完成成员函数IsInclude(int n)的定义,该函数检查参数n是否在类的数据成员数组array中,如果在,返回1,否则返回0。请在注释4之后添加语句。 注意:除在指定位置添加语句之外,不要改动程序中的其他内容。 试题程序: #included<iostream.h> #define MAX_LENGTH 500 class TCArr { public: TCArr() { //********1******** } int AddMember(int n) { for(int i=0;i<length;i++) { //********2******** return 0; } Array[length++]=n; return 1; } int DelMember(int n) { int i; for(i=0;i<length;i++) { if(Array[i]==n) { break; } } //********3******** { for(;r<length-1;i++) { Array[i]=Array[i+1]; } length--; return 1; } return 0; } int IsInclude(int n) { for(int i=0;i<length;i++) { //********4******** { return 1; } } return 0; } private: int Array[MAX_LENGTH]; int length;//用来记录数组的个数 }; int main() { TCArr obj; cout<<obj.AddMember(1)<<endl; cout<<obj.AddMember(3)<<endl; cout<<obj.AddMember(8)<<endl; cout<<obj.AddMernber(23)<<endl; cout<<obj.Islnclude(8)<<endl; cout<<obj.IsInclude(11)<<endl; cout<<obj.DelMember(3)<<endl; cout<<obj.DelMember(8)<<endl; cout<<obj.IsInclude(2)<<endl; cout<<obj.Islnclude(1)<<endl; return 0; }
进入题库练习
问答题综合应用题 使用VC6打开考生文件夹下的工程test2_3。此工程包含一个test2_3.cpp,其中定义了类Stud,但类的定义并不完整。请按要求完成下列操作,将程序补充完整。 (1)定义类的公有数据成员no,name[10],其中no是int型的数据,name[10]是字符型一维数组。请在注释"// ** 1 ** "之后添加适当的语句。 (2)完成函数set的定义,分别将参数n,na的值赋给数据成员no,name。注意:请使用this指针完成对no的赋值,使用字符串函数实现对name和cname的赋值。请在注释"// ** 2 ** "之后添加适当的语句。 (3)完成类的成员函数disp的定义,使其按no,deg,name和cname的顺序输出类的数据成员的值,中间使用跳格符分隔,请在注释"// ** 3 ** "之后添加适当的语句。 输出结果如下: 1 李华 95 990701 2 王东 83 990702 注意:除在指定的位置添加语句外,请不要改动程序中的其他语句。 源程序文件test2_3.cpp清单如下: #include #include class Stud { public: // ** 1 ** int deg; char cname[10]; Stud(){} void set(int n,char na[],int d,char cn[]) { // ** 2 ** deg=d; strcpy(cname,cn); } void disp() { // ** 3 ** } }; void main() { Stud obj[2]; obj[0].set(1,"李华",95,"990701"); obj[1].set(2,"王东",83,"990702"); obj[0].disp(); obj[1].disp(); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi.cpp,该程序运行时有错,请改正其中错误,使得程序正常运行,并使程序输出的结果为: c Test 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在//********error********的下面。#inciude<iostream.h>Void main(){ //********error******** char c="c"; cout<<c<<endl; //********error******** char b=1024; //********error******** b+=1024: if(b==2048) { cout<<"Test"<<endl; } return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数convert(char*strOct)的功能是将八进制转换为十进制。 提示:要每一位转换,然后把转换后得到的数累加起来即可。 注意:不能修改其他部分的代码。 #inClude #include int convert(char*strOct) { } int main() { cout<
进入题库练习