线性表及应用ppt课件.ppt

  1. 1、本文档共49页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
线性表及应用ppt课件

program exp2_1 ; { 用数组完成多项式合并同类项 } const max=100 ; type number =record coef :integer ; exp : 0..100 ; arr= array[1..max] of number ; var S,R,A :arr ; n,m,j,k , x,y : integer ; Procedure input ( var h: arr; t:integer ); Var k,j :integer ; Begin For k:=1 to t do Read(h[k].coef, h[k].exp); Write(‘y=’); For k:=1 to t do begin If ( h[k].coef0 ) and (k1) then write(‘+’) Write( h[k].coef,’X’, h[k].exp, ’ ‘ ) ; End; Writeln ; End; Begin { 主程序 } Write( ‘ input number n, m :’ ); Read(n,m);Writeln; Input( S,n ); input (R,m ); x:=1 ; y:=1; k:=1 ; while (x=n) and (y=m) do begin if s[x].exp=r[y].exp then begin j:=s[x].coef+r[y].coef if j0 then begin a[k].exp:=s[x].exp; a[k].coef:=j; x:=x+1 ; y:=y+1 ; k:=k+1 ; end else begin x:=x+1; y:=y+1 ; end ; end else if s[x].expr[y].exp then begin a[k].exp:=s[x].exp; a[k].coef:=s[x].coef ; x:=x+1 ; k:=k+1 ; end else begin a[k].exp:=r[y].exp; a[k].coef:=r[y].coef ; y:=y+1 ; k:=k+1 ; end ; end; while ( x=n ) and (y m) do begin a[k].exp:=s[x].exp; a[k].coef:=s[x].coef ; x:=x+1 ; k:=k+1 ; end; while ( y=m ) and( xn) do begin a[k].exp:=r[y].exp; a[k].coef:=r[y].coef ; y:=y+1 ; k:=k+1 ; end; write( ‘y3=’); { 输出合并同类项以后的多项式 } for j:=1 to k-1 do begin If ( A[j].coef0 ) and (j1) then write(‘+’); Write(A[j].coef, ‘X’, A[j].exp, ‘ ’ ) ; end; Writeln ; End. 1、双(向)链表中有两条方向不同的链,即每个结点中除next域存放后继结点地址外,还增加一个指向其直接前趋的指针域fro

文档评论(0)

dajia1qi + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档