全文预览

数据结构课程设计---一元多项式的加法、减法、乘法的实现

上传者:幸福人生 |  格式:doc  |  页数:19 |  大小:226KB

文档介绍
le *b,double *c) //顺序结构相加Р{Р?int min=(cp1[n1-1].expn>cp2[n2-1].expn?cp2[n2-1].expn:cp1[n1-1].expn);Р?int max=(cp1[n1-1].expn<cp2[n2-1].expn?cp2[n2-1].expn:cp1[n1-1].expn);Р?int i;Р?for(i=0;i<=min;i++)Р c[i]=a[i]+b[i];Р?for(;i<=max;i++)Р if(cp1[n1-1].expn>cp2[n2-1].expn)Р c[i]=a[i];Р elseР c[i]=b[i];Р?puts("相加结果为:");Р?ansprint(c,max);Р}Рvoid subpoly(double *a,double *b,double *c) //顺序结构相减Р{Р?int min=(cp1[n1-1].expn>cp2[n2-1].expn?cp2[n2-1].expn:cp1[n1-1].expn);Р?int max=(cp1[n1-1].expn<cp2[n2-1].expn?cp2[n2-1].expn:cp1[n1-1].expn);Р?int i;Р?for(i=0;i<=min;i++)Р c[i]=a[i]-b[i];Р?for(;i<=max;i++)Р if(cp1[n1-1].expn>cp2[n2-1].expn)Р c[i]=a[i];Р elseР c[i]=-b[i];Р?puts("相减结果为:");Р?ansprint(c,max);Р}Рvoid mulpoly(double *a,double *b,double *c) //顺序结构相乘Р{Р?int max=cp1[n1-1].expn+cp2[n2-1].expn+2;

收藏

分享

举报
下载此文档