数据结构A第一次实验报告.doc

数据结构A第一次实验报告

实 验 报 告 (20 / 2015 学年 第 学期) 课程名称 实验名称 实验时间 年 月 日 指导单位 系 指导教师 学生姓名 班级学号 学院(系) 专 业 实 验 报 告 实验名称 指导教师 实验类型 实验学时 实验时间 实验目的和要求 (1)线性表操作 在顺序表类SeqList中增加成员函数void Reverse(),实现顺序表的逆置。 在顺序表类SeqList中增加成员函数bool Delete(const T x),删除表中所有元素值等于x的元素。若表中存在这样的元素,则删除之,且函数返回true;否则函数返回false。 编写main函数,调用上述新增函数。 提示:创建LinearList.h,SeqList.h文件包含程序2.1和程序2.2的代码。在其中新增上述两个函数。 (2)一元多项式的相加和相乘 设计带表头结点的单链表表示的多项式类,在该类上定义和实现教材第2.4节中程序2.7的多项式类上的各个运算。 在该类上增加成员函数void PolyMul(Polynominal r),并重载*运算符。 实现菜单驱动的main函数,测试多项式类上各个运算:输入多项式、显示多项式、多项式加法和乘法运算。 二、实验环境(实验设备) 硬件:微型计算机 软件:Windows 操作系统、Microsoft Visual C++6.0 三、实验原理及内容 irtual bool IsEmpty() const=0 + virtual int Length() const=0 + virtual bool Find(int i, T x)const=0 + virtual int Search(T x)const=0 + virtual bool Insert(int i, T x)=0 + virtual bool Delete(int i)=0 + virtual bool Update(int i, T x)=0 + virtual bool Output(ostream out)const=0 父类: SeqList - T* elements - int maxLength + SeqList(int mSize) + ~SeqList() + bool IsEmpty()const + int Length()const + bool Find(int i, T x)const + int Search(T x)const + bool Insert(int i, T x) + bool Delete(int i) + bool Update(int i, T x) + void Output(ostream out)const + void Reverse() + bool Deletevalue(const T x) 子类: 继承关系 (2)一元多项式的加法与乘法 Term - int coef - int exp - Term* link - friend class Polynominal + Term(int c, int e) + Term(int c, int e, Term* nxt) + Term* insertAfter(int c, int e) 实 验 报 告 Term* theList + Polynominal() + ~Polynominal() + void sortPolynominal(Polynominal r) + void addTerms(istream in) + void output(ostream out) const + void polyAdd(Polynominal r) + void polyMult(Polynominal r) + void equivalent(Polynominal r) + friend ostream operator(ostream out,Polynominal x) + friend istream operator(istream in, Polynominal x) + friend Polynominal operator+(Polynominal a, Polynominal b) + friend Polynominal operator*(Polynominal a,Polynominal b) 2、算法与数据结构 (1

文档评论(0)

1亿VIP精品文档

相关文档