计算机类
公务员类
工程类
语言类
金融会计类
计算机类
医学类
研究生类
专业技术资格
职业技能资格
学历类
党建思政类
计算机等级考试(NCRE)
全国计算机应用水平考试(NIT)
计算机软件水平考试
计算机等级考试(NCRE)
全国高校计算机等级考试CCT
行业认证
信息素养
计算机等级考试二级
计算机等级考试一级
网络工程师(计算机等级考试四级)
计算机等级考试二级
数据库工程师(计算机等级考试四级)
计算机等级考试三级
信息安全工程师(计算机等级考试四级)
嵌入式系统开发工程师(计算机等级考试四级)
软件测试工程师(计算机等级考试四级)
C++语言程序设计
Python语言程序设计
WPS Office高级应用与设计
C语言程序设计
C++语言程序设计
Java语言程序设计
Visual Basic语言程序设计
Web程序设计
Access数据库程序设计
MySQL数据库程序设计
Visual FoxPro数据库程序设计
办公软件高级应用
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,该程序运行时有错误,请改正错误,使得程序输出: Hello test 注意:不要改动main函数,不能增行或删行,也不能更改程序的结构,错误的语句在∥********error********的下面。 #include ∥********error******** template void fun(T t) { std::cout VOid fun(bool t) { std::cout<<(t?"Hello”:”Hi”) <
进入题库练习
问答题使用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 endl m, b endl; }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi1.zpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: number1=a number2=a number1=a number2=b 注意:错误的语句在//********error********的下面,修改该语句即可。#include<iostream.h>class CMyClass{public: //********error******** friend void SetValue(CMyClassobj,char c) { obj.numberl=c; obj.number2,=c; } //********error******** void SetValue(CMyClass obj,char c1,char c2) { obj.numberl=c1; obj.number2=c2; } void display() { cout<<"number1="<<numberl<<endl; cout<<"number2="<<number2<<endl; }private: char number1,number2;};Void main(){ CMyClass t; SetValue(t,'a'); t.display(); //********error******** t.SetValue(&t,'a','b'); t.display(); }
进入题库练习
问答题使用VC6打开下的源程序文件modi2.cpp。完成fun()函数,其功能是:求出M行N列二维数组每行元素中的最小值,并计算它们的和值。和值通过形参传回主函数输出。注意:不能修改程序的其他部分,只能修改fun()函数。#include<iostream.h>#defineM2#defineN4voidfun(inta[M][N],int*sum){}voidmain(){intX[M][N]={7,6,5,2,4,2,8,3);ints;fun(x,coutsendl;return;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj2下的工程proj2,其中定义了Employee类和Manager类。Employee用于表示某公司的雇员,其属性包括姓名(name)和工作部分(dept)。Manager是Employee的公有派生类,用于表示雇员中的经理。除了姓名和工作部分之外,Manager的属性还包括级别(level)。Employee类的成员函数print用于输出雇员的信息;Manager类的成员函数print负责输出经理的信息。请在横线处填写适当的代码,然后删除横线,以实现上述类定义。此程序的正确输出结果应为: Name:Sally Smith Dept:Sales Level:2 注意:只能在横线处填写适当的代码,不要改动程序中的其他内容,也不要删除或移动“// ****found****”。 #include <iostream> #include <string> using namespace std; class Employee { public: Employee (string name, string dept): // **********found********** ______ {} virtual void print() const; string dept() const //返回部门名称 { // **********found********** ______ } virtual ~Employee() {} private: string name_; string dept_; }; class Manager: public Employee { public: Manager (string name, string dept, int level): // **********found********** ______ {} virtual void print() const; private: int level; }; void Employee::print() const { cout << "Name:" << name_ << endl; cout << "Dept:" << dept_ << endl; } void Manager::print() const { // **********found********** cout << "Level:" << level_ << endl; } int main() { Employee * emp = new Manager("Sally Smith", "Sales", 2); emp -> print(); delete emp; return 0; }
进入题库练习
问答题使用VC++6.0打开 下的源程序文件2.cpp。请完成以下两个函数。 (1)funl(int n)求出n的阶乘,必须使用递归调用。 (2)fun2(int n)求出n的阶乘,不能使用递归调用。如果n小于1则返回0。 注意:不能修改函数的其他部分。 试题程序: #include<iostream.h> //必须使用递归 int funl(int n) { } //不能使用递归 int fun2(int n) { } void main() { int i; cout<<"请输入一个整数:"<<endl; cin>>i; cout<<"输入数字的阶乘是:"<<funl(i)<<endl; cout<<"输入数字的阶乘是:"<<fun2(i)<<endl; return; }
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj2下的工程proj2,该工程中含有一个源程序文件pmj2.cpp,其中定义了CharShape类、Triangle类和Rectangle类。 CharShape是一个抽象基类,它表示由字符组成的图形(简称字符图形),纯虚函数Show用于显示不同字符图形的相同操作接口。Triangle和Rectangle是Char'Shape的派生类,它们分别用于表示字符三角形和字符矩形,并且都定义了成员函数Show,用于实现各自的显示操作。程序的正确输出结果应为: * *** ***** ******* ######### ######### ######### 请阅读程序,分析输出结果,然后根据以下要求在横线处填写适当的代码并删除横线。 (1)将Triangle类的成员函数Show补充完整,使字符三角形的显示符合输出结果。 (2)将Rectangle类的成员函数Show补充完整,使字符矩形的显示符合输出结果。 (3)为类外函数fun添加合适的形参。 注意:只在指定位置编写适当代码,不要改动程序中的其他内容,也不要删除或移动“//****found****”。//proj2.cpp#include<iostream>using namespace std;class CharShape{public: CharShape(char ch):一ch(ch){); virtual void Show()=0;protected: char ch;//组成图形的字符 }; class Triangle:public CharShape{ public: Triangle(char ch,int r):Char—Shape(ch),一rows(r){) void Show();private: int rows;//行数 }; class Rectangle:publ ic CharShape{ public: Rectangle(char ch,int r,int c):CharShape(ch),_rows(r),_cols(c){) voio Show();private: int rows,cols;//行数和列数 }; void Triangle::Show() //输出字符组成的三角形 { for(int i=1;i<= rows;i++){//********found********for(int j=1;j<=_______;j++) cout << ch; cout<<endl; } } void Rectangle::Show() //输出字符组成的矩形 { //********found********for(int i=1;i<=________;i++} {//********found******** for(int j=1;j<=_______;j++) cout<< ch;cout<<endl; }}//********found******** 为fun函数添加形参VOid fun(_________){CS.Show();)int main(){Triangle tri(’*’,4);Rectangle rect(’#’,3,8);fun(tri);fun(rect);return 0;}
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 proj3下的工程文件proj3,此工程包含一个源程序文件proj3.cpp,其功能是从文本文件in.dat中读取全部整数,将整数序列存放到intArray类的对象myArray中,然后对整数序列按非递减排序,最后由函数writeToFile选择序列中的部分数据输出到文件out.dat中。文件in.dat中的整数个数不大于300个。 要求: 补充编制的内容写在“// **********333**********”与“// **********666**********”两行之间。实现对整数序列按非递减排序,并将排序结果在屏幕上输出。不得修改程序的其他部分。 注意:程序最后已将结果输出到文件out.dat中。输出函数writeToFile已经给出并且调用。 // proj3.cpp #include <iostream> #include <fstream> #include <cstring> using namespace std; class intArray { private: int * array; //整数序列首地址 int length; //序列中的整数个数 public: //构造函数,从文件中读取数据用于初始化新对象。参数是文件名 intArray(char * filename); void sort(); //对整数序列按非递减排序 ~intArray(); void writeToFile (char * filename); }; intArray:: intArray (char * filename) { ifstream myFile(filename); int len=300; array = new int[len]; length = 0; while(myFile >>array[length++]); length--; myFile.close(); } void intArray::sort(){ // **********333********** // **********666********** } intArray:: ~intArray() { delete [] array; } void intArray:: writeToFile (char * filename) { int step=0; ofstream outFile(filename); for(int i=0; i<length; i=i+step) { outFile << array [i] << endl; step ++; } outFile.close(); } void main() { intArray myArray ("in.dat"); myArray.sort(); myArray, writeToFile ("out.dat"); }
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modil.cpp,但该程序运行时有错,请改正程序中的错误,使程序输出的结果为: Number=8 注意:错误的语句在∥********error********的下面,修改该语句即可。 #include class CMyClass { public: ∥********error******** void&Get() { return&Number; } void Set(int m) { Number=m; } void display() { cout<<“Number=”<
进入题库练习
问答题写出下列程序的运行结果。 #include <iostream> using namespace std; class ClassOne { public: ClassOne (); ClassOne (int value); ~ClassOne (); void Print(); private: int i; }; class ClassTwo { public: ClassTwo (); ClassTwo (int value); ~ClassTwo(); void Print(); private: ClassOne myclass; int i; }; ClassOne::ClassOne() :i(0) { cout << "Constructor of ClassOne!" << endl; } ClassOne:: ClassOne(int value) :i(value) { cout << "Constructor of ClassOne! "<< endl; } ClassOne:: ~ClassOne() { cout << "Destructor of ClassOne! " << endl; } void ClassOne::Print() const { cout << "The i of ClassOne is "<< i << endl; } ClassTwo::ClassTwo() :i(0) { cout << "Constructor of ClassTwo!" << endl; } ClassTwo:: ClassTwo(int value) :i(value) { cout << "Constructor of ClassTwo!" << endl; } ClassTwo:: ~ClassTwo() { cout << "Destructor of ClassTwo!" << endl; } void ClassTwo::Print() const { cout << "The i of ClassTwo is" << i << endl; } int main() { ClassTwo myclass(10); myclass.Print(); return 0; }
进入题库练习
问答题使用VC6打开下的源程序文件modi2.cpp。完成函数fun(char*str,char*s)空出部分。函数fun(cha*sir,char*s)的功能是:将在字符串str中下标为偶数位置上的字符,紧随其后重复出现一次,放在一个新串s中,s中字符按原字符串中字符的顺序排列。(注意0为偶数)例如:当str中的字符串为:"abcdef"时,s中的字符串应为:"aaccee"。注意:不要改动main()函数,不得增行或删行,也不得更改程序的结构。#include<iostream.h>voidfun(char*str,char*s){}voidmain(){charstr[100],s[100];cout"Pleaseenterstringstring:"endl;cin.getline(str,100);fun(str,s);cout"Theresultis:"sendl;return;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。阅读下列函数说明和代码,完成空出部分程序。函数fun(intn)的功能是在n行n列的矩阵中,每行都有最大的数,本程序求这n个最大数中的最小一个,并作为参数返回。 注意:不能修改程序的其他部分,只能修改fun()函数。 #include #define N 100 int a[N][N]; int fun(int n) { } void main() { int n ; cout>n; for(int i=0 ;i>a[i][j]; } cout<<”The min of max numbers —is”(
进入题库练习
问答题请使用VC6或使用【答题】菜单打开考生文件夹proj3下的工程prog3,其中声明了MyString类。MyString是一个用于表示字符串的类。成员函数startsWith的功能是判断此字符串是否以指定的前缀开始,其参数8用于指定前缀字符串。如果参数s表示的字符串是MyString对象表示的字符串的前缀,则返回true;否则返回false。注意,如果参数S是空字符串或等于MyString对象表示的字符串,则结果为true。例如,字符串“abc”是字符串“abcde”的前缀,而字符串“abd”不是字符串“abcde”的前缀。请编写成员函数startsWith。在main函数中给出了一组测试数据,此种情况下程序的输出应为:s1=abcdes2=abcs3=abds4=s5=abcdes6=abcdefs1startsWiths2:trues1startsWiths3:falses1startsWiths4:trues1startsWiths5:trues1startsWiths6:false要求:补充编制的内容写在“//**********333**********”与“//**********666**********”之间,不得修改程序的其他部分。注意:程序最后将结果输出到文件out.dat中。输出函数writeToFile已经编译为obj文件,并且在本程序中调用。//MyStving.h#include<iostream>#include<string.h>usingnamespacestd;classMyString{public:MyString(constchar*s){size=strlen(s);str=newchar[size+1];strcpy(str,s);}~MyString(){delete[]str;)boolstartsWith(constchar*s)const;private:char*str;intSize;};voidwriteToFile(constchar*);//main.cpp#include"MyString.h"boolMyString::startsWith(constchar*s)const{//********333********//********666********}intmain(){chars1[]="abcde";chars2[]="abc";chars3[]="abd";chars4[]="";chars5[]="abcde";chars6[]="abcdef";MyStringstr(s1);cout<<"s1="<<s1<<end1<<"s2="<<s2<<end1<<"s3="<<s3<<end1<<"s4="<<s4<<end1<<"s5="<<s5<<end1<<"s6="<<s6<<end1;cout<<boolalpha<<"s1startSWiths2:"<<Str.startsWith(s2)<<end1<<"s1startSWiths3:"<<str.startsWith(s3)<<end1<<"s1StartSWiths4:"<<Str.startsWith(s4)<<end1<<"s1startSWiths5:"<<Str.startsWith(s5)<<end1<<"s1StartsWiths6:"<<Str.startsWith(s6)<<end1;writeToFile("");return0;}
进入题库练习
问答题请编写一个函数int sum(int n),该函数完成1+2+3+…+n的运算,并返回运算结果,其中n>0。注意:请使用递归算法实现该函数。 注意:部分源程序已存在文件:test11.cpp中。 请勿修改主函数main和其他函数中的任何内容,仅在函数sum的花括号中填写若干语句。 文件test11_2.cpp的内容如下: #include<iostream.h> int sum(int n) { } void main() { int n; cout<<"输入n:"; cin>>n; int result;sum(n); cout<<"结果为:"<<result<<endl; }
进入题库练习
问答题使用VC6打开考生文件夹下的工程RevProj9。此工程包含一个源程序文件RevMain9.cpp。在该文件中,函数fun()的功能是;将字符串s中的小写字母都改为对应的大写字母,其他字符不变。例如,输入“mT+gN”,则输出“MT+GN”。 请改正程序中的错误,使它能得到正确结果。 注意,不要改动main函数,不得删行或增行,也不得更改程序的结构。 源程序文件RevMain9.cpp中的程序清单如下; //RevMain9.cpp #include<iostream> using namespace std; char* fun(char*s); int main() int i; char str[81]; cout<<"Please enter a string:"; cin>>str; cout<<"/n The result is:/n"<<fun(str)<<end1; return 0; char *fun(char*s) int i; for(i=0;s[i];i++) /* * * * *FOUND* * * * * if(('a'<=s[i])||(s[i]<:='z')) /* * * * *FOUND * * * * * / s[i]+=32; return s;
进入题库练习
问答题请使用VC6或使用【答题】菜单打开 prog3下的工程prog3,其中包含了类TaxCalculator(“个税计算器”)和主函数main的定义。创建“个税计算器”需要接收税率表信息和起征额信息。在main函数中,通过两个数组创建了如下的税率表: 下标 适用收入段下限 (lower_limits) 适用税率 (rates) 说明: 适用的收入段为 0 0 5 大于0小于等于500 1 500 10 大于500小于等于2000 2 2000 15 大于2000小于等于5000 3 5000 20 大于5000小于等于20000 4 20000 25 大于20000小于等于40000 5 40000 30 大于40000小于等于60000 6 60000 35 大于60000小于等于80000 7 80000 40 大于80000小于等于100000 8 100000 45 大于100000 利用这个税率表创建“个税计算器”时,假定起征额为2000元(即不超过2000元的所得不征收个人所得税)。请补充完成计算应纳个人所得税额的成员函数getTaxPayable,其中的参数income为月收入。此程序的正确输出结果应为: 月收入为800元时应缴纳个人所得税0元 月收入为1800元时应缴纳个人所得税0元 月收入为2800元时应缴纳个人所得税55元 月收入为3800元时应缴纳个人所得税155元 月收入为4800元时应缴纳个人所得税295元 月收入为5800元时应缴纳个人所得税455元 注意:只能在函数getTaxPayable中的“// ********333********”和“// ********666********”之间填入若干语句,不要改动程序中的其他内容。 //TaxCalculator.h #include <iostream> #include <iomanip> using namespace std; class TaxCalculator{ public: TaxCalculator (double the_limits[], double the_rates[], int the_length, double the_threshold) : lower_limits (new double[the_length]), rates(new double[the_length]), list_len (the_length), threshold(the_threshold) { for(int i = 0; i < list_len; i++){ lower_limits[i] = the_limits[i]; rates[i] = the_rates[i]; } } ~TaxCalculator() {delete[]lower_limits; delete[] rates;] double getTaxPayable (double income)const; //返回指定月收入的应纳个人所得税额 void showTaxPayable (double income) const; //显示指定月收入的应纳个人所得税额 private: double * lower limits; //适用收入段下限 double * rates; //适用税率 int list_len; //税率表项数 double threshold; //起征额 }; void writeToFile(const char * path); //TaxCalcnlator.cpp #include "TaxCalculator.h" double TaxCalculator::getTaxPayable(double income) const { double taxable = income-threshold; //应纳税工资额 double tax_payable = 0.0; //应纳个人所得税额 int i=list len-1; while(i >= 0){ // ********333******** // ********666******** --i; } return taxpayable; } void TaxCalculator::showTaxPayable (double income) const { cout << "月收入为" << setw(6) << income << "元时应缴纳个人所得税" <<setw(4) << getTaxPayable (income) << "元" << endl; } //main.cpp #include "TaxCalculator.h" int main(){ double limits[] = {0.0, 500.0, 2000.0, 5000.0, 20000.0, 40000.0, 60000.0, 80000.0, 100000.0}; double rates[] = {0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.35, 0.4, 0.45}; TaxCalculator calc (limits,rates,9,2000.0); calc.showTaxPayable(800.0); calc.showTaxPayable(1800.0); calc.showTaxPayable(2800.0); calc.showTaxPayable(3800.0); calc.showTaxPayable(4800.0); calc.showTaxPayable(5800.0); writeToFile(" "); return 0; }
进入题库练习
问答题请编写一个函数int fun(int n),其中n为自然数。函数fun()的功能是求出自然数n(包括n)以内所有素数的和,并返回其值。 注意;部分源程序已存在文件PROC11.cpp中。 请勿修改主函数和其他函数中的任何内容,仅在函数fun()的花括号中填写若干语句。 文件PROC11.cpp的内容如下: //PROC11.cpp #include<iostream> using namespace std; int fun(int n); int main() int number; cout<<"Enter the number which you want to caculate: /n"; cin>>number; cout<<"The result is:"<<fun(number)<<end1; return 0; int fun(int n) //* * * * * * * * *
进入题库练习
问答题使用VC6打开下的源程序文件modi3.cpp。通过继承完成输入到屏幕指定的信息:TlestClassATestClassBTlestClassC其中定义的类并不完整,按要求完成下列操作,将类的定义补充完整。(1)完成类B虚继承于A,请在注释//********1********后添加适当的语句。(2)完成类C虚继承于A,请在注释//********2********后添加适当的语句。(3)完成类D继承于B,C,请在注释//********3********后添加适当的语句。(4)函数fun通过调用基类的fun,完成所输出的内容,请在注释//********4********后添加适当的语句。注意:增加代码,或者修改代码的位置已经用符号表示出来。请不要修改其他的程序代码。#include<iostream.h>classTestClassA{public:voidfun(){cout"TestClassA"endl;}};//********1********classTestClassB{public:voidfun(){cout"TestClassB"endl;}};//********2********classTestClassC{public:voidfun(){cout"TestClassC"endl;}};//********3********classTestClassD{public:voidfun(){//********4********}};voidmain(){TestClassDtest;test.fun();return;};
进入题库练习
问答题使用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>using namespace std;void WriteFile(int c){ ofstream out1; out1.open("modi3.txt",ios_base::app); out1<<c<< ' '; out1.Close();}void WriteFile(char* str){ Ofstream out1; out1.open("modi3.txt",ios_base::app); out1<<Str;out1.close();}void ClearFile(){ ofstream out1; out1.open("modi3.txt");out1.Close();}Class Date{public: Date(int y,int m,int d) { //********2******** } void print()const; //********3******** { month+=m; int i=month/12; int j=month%12; if(j=0) { year+=(i-1); month=12; } elase { year+=i; month=j; } return *this; }private: //********1********};void Date::print()const{ //********4******** WriteFile(year); WriteFile("年"); WriteFile(month); WriteFile("月"); WriteFile(day); WriteFile("日");}int main(){ ClearFile(); Date Oly day(2008,8,8); Oly_day+=3; Oly_day.print(); return 0;}
进入题库练习
问答题使用VC6打开考生文件夹下的源程序文件modi2.cpp。完成函数fun(char*str,char*s)空出部分。函数fun(char*str,char*s)的功能是:将在字符串str中下标为偶数位置上的字符,紧随其后重复出现一次,放在一个新串S中,S中字符按原字符串中字符的顺序排列。(注意0为偶数) 例如:当str中的字符串为:“abcdef”时,S中的字符串应为:“aaccee”。 注意:不要改动main()~数,不得增行或删行,也不得更改程序的结构。 #include VOid fun(char*str,char*S) { } void mein() { char str[1 0 0],s[1 0 0]; cout<<”Please enter string string:”<
进入题库练习