数据结构课设代码

数据结构课设代码

ID:28357794

大小:62.00 KB

页数:15页

时间:2018-12-09

数据结构课设代码_第1页
数据结构课设代码_第2页
数据结构课设代码_第3页
数据结构课设代码_第4页
数据结构课设代码_第5页
资源描述:

《数据结构课设代码》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、-程序如下:#include#include#include#include#include#include#includeusingnamespacestd;enumError_code{success,fail,range_error,underflow,overflow,fatal,not_present,duplicate_error,entry_inserted,entry_found,internal_error}

2、;//enumkind{cigarette,water,gum,beer,bread};templatestructNode{stringkind1;Node_entryprice;Node_entryshelf;Node*next;Node();Node(stringkind_1,Node_entryprice2,Node_entryshelf2,Node*link);};templateNode::Node(){nex

3、t=NULL;}templateNode::Node(stringkind_1,Node_entryprice2,Node_entryshelf2,Node*link=NULL){kind1=kind_1;price=price2;shelf=shelf2;next=link;}template.---classList{public:Error_codeinsert(List&list,conststring&kind_1,constList_

4、entry&price2,constList_entry&shelf2);Error_coderemove(List&list,string&kind_1,List_entry&price2,List_entry&shelf2);Error_codereplace(List&list,conststring&kind_1,constList_entry&price2,constList_entry&shelf2);Error_coderetrieve(List&list,string&kind_1,List_entry&price2,List_entry&sh

5、elf2)const;voidsort();List();intsize()const;boolfull()const;boolempty()const;voidclear();voidtraverse(void(*visit)(List_entry&));~List();List(constList©);voidoperator=(constList©);voidsavedate(List&list);voidloaddate(List&list)

6、;protected:intcount;Node*head;Node*set_position(intposition)const;};templateError_codeList::insert(List&list,conststring&kind_1,constList_entry&price2,constList_entry&shelf2){intposition=list.size();if(position<0

7、

8、position>count)r

9、eturnfail;Node*new_node,*previous,*following;if(position>0){previous=set_position(position-1);following=previous->next;}elsefollowing=head;new_node=newNode(kind_1,price2,shelf2,following);if(new_node==NULL)returnoverflow;.---if(position==0)head=new_node;elsep

10、revious->next=new_n

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。