其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
多项式相加的链表实现

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

多项式相加的链表实现



program ex11_5b;

type

link=^node;

node=record

zhi,xi:integer;

nxt:link;

end;

var

a,b:link;

n:integer;

procedure createfifo(var c:link);{建立多项式系数、指数链表}

var

p:link;

i:integer;

begin

new(p);

readln(p^.xi,p^.zhi);

c:=p;

for i:=1 to n-1 do

begin

new(p^.nxt);p:=p^.nxt;readln(p^.xi,p^.zhi);

end;

p^.nxt:=nil;

end;

begin

write('One : '); readln(n); createfifo(a);

write('Two : '); readln(n); createfifo(b);

write('Result is ');

while (a<>nil) and (b<>nil) do

begin

if a^.zhi>b^.zhi then

begin

if a^.xi<0 then write(#8' '#8);

write(a^.xi,'x',a^.zhi,'+');

a:=a^.nxt;

end

else

if a^.zhi
begin

if b^.xi<0 then write(#8' '#8);

write(b^.xi,'x',b^.zhi,'+');

b:=b^.nxt;

end

else

begin

if b^.xi+a^.xi<>0 then

begin

if b^.xi+a^.xi<0 then write(#8' '#8);

write(b^.xi+a^.xi,'x',b^.zhi,'+');

end;

b:=b^.nxt;

a:=a^.nxt;

end;

end;

while a<>nil do

begin

if a^.xi<0 then write(#8' '#8);

write(a^.xi,'x',a^.zhi,'+');

a:=a^.nxt;

end;

while b<>nil do

begin

if b^.xi<0 then write(#8' '#8);

write(b^.xi,'x',b^.zhi,'+');

b:=b^.nxt;

end;

writeln(#8' '#8);

readln;

end.



相关文章

相关软件