单链表的就地逆置.docx

上传人:牧羊曲112 文档编号:3346904 上传时间:2023-03-12 格式:DOCX 页数:2 大小:36.57KB
返回 下载 相关 举报
单链表的就地逆置.docx_第1页
第1页 / 共2页
单链表的就地逆置.docx_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《单链表的就地逆置.docx》由会员分享,可在线阅读,更多相关《单链表的就地逆置.docx(2页珍藏版)》请在三一办公上搜索。

1、单链表的就地逆置#include #include #include #define NULL 0 #define OK 1 typedef int ElemType; typedef int Status; /-单链表的存储结构-/ typedef struct LNode ElemType data; struct LNode *next; LNode,*LinkList; void CreastList_L(LinkList &L,int n)/创建带头结点的单链表L LNode *p,*q; int i; L=(LNode*)malloc(sizeof (LNode); L-next=

2、NULL; /先建立一个带头结点的单链表 p=L; for (i=1;idata); /输入元素值 q-next=NULL; p-next=q; p=q; void ListInverse_L(LinkList &L)/单链表的就地逆置 LNode *p,*q; p=L-next; L-next=NULL; while(p!=NULL) q=p-next; p-next=L-next; L-next=p; p=q; void PrintList(LinkList &L)/输出单链表 LNode *p=L-next; while(p!=NULL) printf(%d,p-data); p=p-next; void main int n; LinkList La; printf(Input the list num:); scanf(%d,&n); CreastList_L(La,n); printf(Before Inverse the list is:); PrintList(La); ListInverse_L(La); printf(nAfter Inverse the list is:); PrintList(La); printf(n);

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

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号