尾插法建立一元多项式的链表
更新时间:2023-12-09 14:34:01 阅读量: 教育文库 文档下载
- 用尾插法建立一个循环链表推荐度:
- 相关推荐
实验报告
2009级 数学与应用数学班 2011年11月19日 姓名: 学号: 1、 实验目的
用尾插法建立一元多项式的链表,验证是否实现,并进行两个多项式的相加运算 2、 需求分析
本程序用TC编写,完成尾插法一元多项式的链表,并验证,及完成相加运算。
① 输入的形式和输入值的范围:输入多项式每一项的系数、指数,输入的所有系数
和指数均为整数。 ② 输入的形式:输出多项式各项的系数、指数。
③ 程序所能达到的功能:完成单链表的建立,及相加操作。 ④ 测试数据:1+1
多项式1: 2x^0+3x^3+7x^5 多项式2: 4x^1+3x^3+-4x^5
3、 概要设计
本程序有两个程序段:
a. 主函数 main;
b. 创建多项式函数 polycreate; c. 多项式相加函数 polyadd;
d. 多项式输出函数 print;
4、 详细设计 #include
typedef struct Polynode {
int coef; int exp;
struct Polynode *next; }Polynode ,*Polylist; Polylist polycreate() {
Polynode *head,*rear,*s; int c,e;
head=(Polynode*)malloc(sizeof(Polynode)); rear=head;
scanf(\ while(c!=0) {
s=(Polynode*)malloc(sizeof(Polynode)); s->coef=c; s->exp=e;
rear->next=s;
rear=s; scanf(\ }
rear->next=NULL;
return(head); } main() {
printf(\
用尾插法建一个一元多项式链表
Void polyadd(Polylist polya,Polylist polyb) {
Polynode *p,*q,*tail,*temp; int sum;
P=polya->next; q=polyb->next; tail=polya; While(p!=NULL&&q!=NULL) {
If(p->exp
{tail->exp=p;tail=p;p=p->next;} Else if(p->exp==q->exp)
{sum=p->coef+q->coef; If(sum!=0)
{p->coef=sum;tail->next=p;tail=p;
P=p->next;temp=q;q=q->next;free(temp);} else
{temp=p;p=p->next;free(temp); Temp=q;q=q->next;free(temp); } }
else
{tail->next=q;tail=q;q=q->next;} }
If (p!=NULL) tail->next=p; else tail->next=q; }
多项式相加函数 Void printf (polylist p) {
While (p!=NULL)
{printf (“%dx^%d+”,p->exp); P=p->next;} }
多项式输出函数
5、 测试结果 2 2,0
3,3 7,5 0,0 4,1 3,3 -4,5 0,0
2x^0+4x^1+6x^3+3x^5
正在阅读:
尾插法建立一元多项式的链表12-09
概论纲要教学部2016年度工作总结3305-04
影视作品分析指导大全 电视片观赏分析提纲(绝对有用)08-24
给幼儿教师的一把钥匙07-23
河北省承德市2022_2022学年高二语文下学期第一次月考试题(新)04-10
弗莱登塔尔的思想03-18
餐饮标准化生产的几点建议04-21
2016新疆公务员申论热点02-08
模糊PID控制在光伏发电MPPT中的应用11-17
- exercise2
- 铅锌矿详查地质设计 - 图文
- 厨余垃圾、餐厨垃圾堆肥系统设计方案
- 陈明珠开题报告
- 化工原理精选例题
- 政府形象宣传册营销案例
- 小学一至三年级语文阅读专项练习题
- 2014.民诉 期末考试 复习题
- 巅峰智业 - 做好顶层设计对建设城市的重要意义
- (三起)冀教版三年级英语上册Unit4 Lesson24练习题及答案
- 2017年实心轮胎现状及发展趋势分析(目录)
- 基于GIS的农用地定级技术研究定稿
- 2017-2022年中国医疗保健市场调查与市场前景预测报告(目录) - 图文
- 作业
- OFDM技术仿真(MATLAB代码) - 图文
- Android工程师笔试题及答案
- 生命密码联合密码
- 空间地上权若干法律问题探究
- 江苏学业水平测试《机械基础》模拟试题
- 选课走班实施方案
- 多项式
- 一元
- 建立
- 官方整理:Excel表格常用快捷键知识库
- 世界现代设计史(考研重点笔记整理)
- 关于印发公路工程竣交工验收办法实施细则的通知(交公路发〔2010〕65号) - 图文
- 井下电气三大保护与完好防爆标准
- 土石混填试验段施工总结2- 2015.10.12 - 图文
- 六年级语文上册复习教案
- 《前行广释》1-3册考试复习范围100题
- 初中常见物质化学式及俗称及重要性质和用途
- windows7操作系统专项习题
- 谐波次数越高幅值越小
- 吴翼IOI2010参赛总结
- 天津市2013届高三高考压轴卷数学(文)试题 - 图文
- 化工原理传热练习题
- 欧姆定律笔记
- 翻转课堂与WebQuest相结合的教学模式对会计专业教学改革的启示
- 自然辩证法概论心得体会
- 生物选修三测试题(全) - 图文
- 牛津沪教版六年级英语6BUnit1-3复习
- 图形推理技巧之答案选项法巧解图形推理题
- 管理系08级毕业生实习报告的规范(模板) - 图文