渭南广电客服电话:用pascal将中缀表达式转化为后缀表达式

来源:百度文库 编辑:查人人中国名人网 时间:2024/04/30 02:54:32
教教我 我不会 最好写个程序出来我看看

原理我也知道 用栈做 可是我就是写不出来程序

麻烦大侠帮忙写出来好吧...
program biaoda(input,output);
const maxn=80;
type stack=array[1..maxn] of char;
var
schar,sword:stack;
char,word,topc,topw,i:integer;
x:string;

begin
readln(x);
topc:=0;topw:=0;char:=0;word:=0;
for i:=1 to length(x) do
if not(x[i]='+') or not(x[i]='-')or not(x[i]='*')or not(x[i]='/') then
begin
topw:=topw+1;
sword[topc]:=x[i];
end
else if (x[i]>=schar[topc]) then
begin
topc:=topc+1; schar[topc]:=x[i];
end
else begin
while (x[i]<schar[topc]) do
begin
topw:=topw+1;
sword[topw]:=schar[topc];
topc:=topc-1;
end;
end;
end.

没人回答么? 帮我看下这个程序 我不知道哪出问题了