将链表分为a,b两个奇偶链表代码

上传人:ji****n 文档编号:46008201 上传时间:2018-06-20 格式:DOC 页数:3 大小:63KB
返回 下载 相关 举报
将链表分为a,b两个奇偶链表代码_第1页
第1页 / 共3页
将链表分为a,b两个奇偶链表代码_第2页
第2页 / 共3页
将链表分为a,b两个奇偶链表代码_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《将链表分为a,b两个奇偶链表代码》由会员分享,可在线阅读,更多相关《将链表分为a,b两个奇偶链表代码(3页珍藏版)》请在金锄头文库上搜索。

1、#include enum error_codesuccess,arrange_error; typedef struct node int data; struct node*next; node; class list public: list();void creat_R();int length()const; node*get_head() return head; void display(); private: int count; node*head; ; list:list () head=new node; head-next =NULL; count=0; int lis

2、t:length ()const return count; void list:creat_R () int x; cinx; node*rear=head; while(x!=-1) count+; node*s=new node; s-data =x; s-next =NULL; rear-next =s; rear=s; cinx; void list:display ()node*p=head-next ; while(p!=NULL) coutdata next ; void divide(list node*pb=b.get_head (); node*u,*v; while(p

3、a-next !=NULL) if(pa-next-data %2=0) v=new node; u=pa-next ; v-data =u -data ; v-next =NULL; pb-next =v; pb=v; pa-next =u-next ; delete u; else pa=pa-next ; void main() list a,b; cout“请输入 A 链表:“; a.creat_R (); cout“输出 A 链表:“; a.display (); coutendl; divide (a,b); cout“输出操作后的 A 链表:“; a.display (); coutendl; cout“输出 B 链表:“; b.display ();

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 初中教育

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号