设为首页 加入收藏

TOP

单链表实现多项式的相乘(二)
2014-11-23 21:34:25 来源: 作者: 【 】 浏览:9
Tags:单链表 实现 多项 相乘
>next; } else { if(pa->exp+pb->expnext; else pa=pa->next; //大于k 减小pa } } if(ceof!=0.0) //有系数了 就将此节点插入到c链表中 { if(NULL==(newnode=(listnode *)malloc(sizeof(listnode)))) { printf("链表C节点开辟失败"); exit(-1); } newnode->coef=ceof; newnode->exp=k; newnode->next=NULL; //插入节点数据 pc->next=newnode; pc=newnode; //插入节点 ceof=0.0; } } InverseList(head_b); return head_c; } int InverseList(listnode *head) //逆置链表 { listnode *p=head->next,*q; //p指向正要逆置的节点,q指向下一个待逆置的节点 head->next=NULL; while(p) //当前节点不为空 { q=p->next;//保存下一个节点 p->next=head->next; //先更新逆置点的 next head->next=p; //在更新head->next p=q; //下一轮 } return 0; }

首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇POJ 2400 最小权匹配 下一篇 hdu4288 Coder

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·Redis on AWS:Elast (2025-12-27 04:19:30)
·在 Spring Boot 项目 (2025-12-27 04:19:27)
·使用华为开发者空间 (2025-12-27 04:19:24)
·Getting Started wit (2025-12-27 03:49:24)
·Ubuntu 上最好用的中 (2025-12-27 03:49:20)