pascal 后缀表达式转中缀表达式 20分!!!急求!!!

来源:百度知道 编辑:UC知道 时间:2024/07/08 19:07:18
pascal 后缀表达式转中缀表达式
要可以用数字的如 且 以'@'结尾
如:
489 489 - 10 11 49 - 44 / * + 491 49 499 + * + @
化为:
489-489+10*(11-49)/44+491*(49+499)

program p1293;
const maxL = 1000000;
type node = record
ch:char;
l,r:longint;
end;
var s:ansistring;
List:array[1..maxL] of node;
T:longint;

function GetLevel(x:char):longint;
begin
case x of
'*','/':exit(3);
'-':exit(1);
'+':exit(1);
end;
end;

procedure work(var s:ansistring);
var now:longint;
begin
inc(T);
now:=T;
List[now].ch:=s[length(s)];
delete(s,length(s),1);
if List[now].ch in ['+','-','*','/'] then begin
List[now].R:=T+1;
work(s);
List[now].L:=T+1;
work(s);
end
else begin
List[now].R:=-1;
List[now].L:=-1;
end;
end;

function outp(x:longint;level:longint;c:longint;d:char):ansistring;
var tmps:ansistring;
nowLevel:longint;
begin
if List[x].ch in ['+','-&#