号中填写若干语句.
文件PROC2.CPP的内容如下:
#include
int find(char s[],char t[]);
const int MAXLINE =256;
int main()
{ char source[MAXLINE],rarget[MAXLINE];
cout <<"Please input a string for searching:\n";
cin.getline(source,MAXLINE);
cout<<"Please input a string you want to find:\n";
cin.getline(target,MAXLINE);
int intpos = find(source,target);
if(intpos>=0
cout<<"Finding it.The target string is at index"
< else
cout<<"Not finding it.\n";
return 0;
}
int find(char s[],char t[])
{
}
3.使用VC6打开考生文件夹下的工程proj3.此工程包含一个源程序文件main.cpp.其中定义了用于表示日期的类Date,但类Date的定义并不完整.请按要求完成下列操作,将类Date的定义补充完整:
(1)定义私有数据成员year,month和day分别用于表示年,月,日,它们都是int型的数据.请在注释"// * * 2
* *"之后添加适当的语句.
(2)完成默认构造函数Date的定义,使Date对象的默认值为:year=1,month=1,day=1,请在注释"// *
* 2 * *"之后添加适当的语句.
(3)完成重载构造函数Date(int y,int m,int
d)的定义,把数据成员year,month和day分别初始化为参数y,m,d的值,请在注释"//* * 3 *
*"之后添加适当的语句.
(4)完成成员函数print的类外定义,使其以"年-月-日"的格式将Date对象的值输出到屏幕上.请在注释"//* * 4
* *"之后添加适当的语句.
注意:除在指定位置添加语句之外,请不要改动程序中的其他内源程序文件main.cpp清单如下:
//main.cpp
#include
class Date{
public:
//* * 2 * *
Date(int y,int m,int d)
{
//* * 3 * *
}
void print() const;
private:
// date members
//* * 1 * *
};
void Date::print()const
{ //* * 4 * *
}
int main()
{ Date national_day(1949,10,1);
national_day.print();
return 0;
}
参考答案
公共基础知识
一:选择题:
(1) D (2) C (3) D (4) B
二:填空题:
(1)[1]:O(Nlog2N)
(2)[2]:功能模型
(3)[3]:软件外部功能
(4)[4]:二维表
C++程序设计
一:选择题
1-5 :B B C C C
6-10:D B C A B
二:填空题
(1)[1]:1 2 5 11 21
(2)[2]:private 或 私有
(3)[3]:抽象类
(4)[4]:templateT DBL(T n){return n+n;}
(5)[5]:int GetNum(){return x;} 或 int GetNum() const{return x;}
责任编辑:小草