收藏 分享(赏)

数据结构与算法代码.doc

上传人:kpmy5893 文档编号:12239018 上传时间:2021-12-05 格式:DOC 页数:2 大小:27KB
下载 相关 举报
数据结构与算法代码.doc_第1页
第1页 / 共2页
数据结构与算法代码.doc_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

1、#includeusing namespace std;typedef struct lint data;struct l *next;T;T * creation()/创建链表T *head,*p;int f=1,d;head=new T;p=head;coutd;head-data=d;doT *temp =new T;cind;if(d!=0)temp-data=d;p-next=temp;p=temp;else f =0;while(f);p-next=NULL;return head;T *reverse(T *head) /链表的逆置if(head=NULL | head-next

2、=NULL)return head;T *p1, *p2, *p3;p1 =head;p2=head-next;dop3 = p2-next ;p2-next = p1;p1 = p2;p2 = p3;while(p2);head-next=NULL;head =p1;return head;void show(T *head)/输出链表if(head=NULL)coutdata next ;while(head!=NULL);coutendl;int main()T *head;head=creation();cout“输入的链表为:“endl;show(head);cout“此链表的逆置为:“endl;head=reverse(head);show(head);return 0;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报