南邮数据结构实验一.doc

  1. 1、本文档共14页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
南邮数据结构实验一

实 验 报 告 (20 / 2015 学年 第 学期) 课程名称 实验名称 实验时间 年 9 月 28 日 指导单位 系 指导教师 学生姓名 陈明阳 班级学号 学院(系) 贝尔英才 专 业 信息科技强化班 实 验 报 告 实验名称 指导教师 实验类型 验证 实验学时 实验时间 9.28 实验目的和要求 二、实验环境(实验设备) VSUAL STUDIO2015 三、实验原理及内容 L(seqlist(LA,LB 函数调用数据类型如下图 源码: Linearlist.h: #includeiostream using namespace std; template class T class LinearList { public: virtual bool IsEmpty() const = 0; virtual int Length() const = 0; virtual bool Find(int i, Tx) 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 void Output(ostream out) const = 0; protected: int n; }; Seqlist.h: #includelinearlist.h templateclass T class SeqList :public LinearListT { public: SeqList(int mSize); ~SeqList() { delete[] elements; } 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; private: int maxLength; T *elements; }; templateclass T SeqListT::SeqList(int mSize) { maxLength = mSize; elements = new T[maxLength]; n = 0; } templateclass T bool SeqListT::IsEmpty() const { return n == 0; } templateclass T int SeqListT::Length()const { return n; } templateclass T bool SeqListT::Find(int i, T x)const { if (i0 || in - 1) { cout out of bounds endl; return false; } x = elements[i]; return true; } templateclass T int SeqListT::Search(T x)const { for (int j = 0; j n; j++) if (elements[j] == x)return j; return -1; } templateclass T bool SeqListT::Insert(int i, T x) { if (i-1 || in - 1) { cout out of bounds endl; return false; } if (n == maxLength) { cout over flow endl; return false; } for (int j = n - 1; j i; j--)elements[j + 1] = elements[j]; elements[i + 1] = x; n++; return true; } templateclass T bool SeqListT::Delete(int i) { if (i0 || in - 1) { cout out of bounds endl; return fa

文档评论(0)

ccx55855 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档