线性表顺序表稀疏矩阵字符串.ppt

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

线性表 顺序表 稀疏矩阵 字符串 ;一、线性表;线性表是最简单的也是最基本的数据结构。;二、顺序表——线性表的顺序表示 ;类模版 通用数据类型 //array.h 例. 通用数组 抽象数组类型 template class T class Array { T *alist; //指针数据 表示一个数组 int size; //表示数组长度 public: Array(int s=50) //构造函数 Array(const ArrayTX); //拷贝构造函数 ~Array( ){delete[ ] element;} //析构函数 ArrayToperator=(const ArrayTX);// 赋值函数重载 T operator[ ](int i); //一元运算[ ]重载 下标函数 operator T*( )const; //强制类型转换,将当前 //对象变成指向它的首地址的指针, int ArraySize( )const; //取数组长 void Resize(int sz); //数组长重定义 friend ostream operator(ostream, const ArrayT); //输出操作重载 }; ;#include array.h;// list modification methods线性表的修改操作;// constructor. set size to 0;// return number of elements in list;// tests for an empty list;// clears list by setting size to 0;// Take item as key and search the list. //return True if item is in the list and ;while(isize !(item==listitem[i]));// insert item at the rear of the list. ;templateclass T //在第i位插入; //shift the tail of the list //to the right one position ;//search for item in the list //and delete it if found;// shift the tail of the list //to the left one position;//delete element at front of list and return // its value. terminate the program with // an error message if the list is empty.; frontItem = listitem[0]; // get value from position 0. Delete(frontItem); // delete the first item and shift terms return frontItem; // return the original value };// return value at position pos in list. // if pos is not valid list position, // teminate program with an error message. templateclass T T SeqListT::GetData(int pos) const { // terminate program if pos out of range if (pos 0 || pos = size) {cerr pos is out of range! endl; exit(1); } return listitem[pos]; };测试; for(i=0;

文档评论(0)

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

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

1亿VIP精品文档

相关文档