求值后缀表达式 3 5*6 7+11/ -

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/29 10:19:36

求值后缀表达式 3 5*6 7+11/ -
求值后缀表达式 3 5*6 7+11/ -

求值后缀表达式 3 5*6 7+11/ -
program hzbds_1010;
type stack=record
data:array[1..100] of real;
top:0..100;
end;
var s:stack;
ch:char;
i:integer;
x:real;
a:array[1..10] of char;
function pop(var s:stack):real; {enter}
begin
pop:=s.data[s.top];
s.top:=s.top-1;
end;
procedure push(var s:stack;x:real); {out}
begin
s.top:=s.top+1;
s.data[s.top]:=x;
end;
{main}
begin
i:=0;
repeat
i:=i+1;
read(a[i]);
until a[i]='@';
s.top:=0;
i:=1;
ch:=a[i];
while ch'@'do
begin
case ch of
'0'..'9':begin
x:=0;
while ch' 'do
begin
x:=x*10+ord(ch)-ord('0');
i:=i+1;
ch:=a[i];
end;
end;
'+':x:=pop(s)+pop(s);
'-':begin x:=pop(s);x:=pop(s)-x; end;
'*':x:=pop(s)*pop(s);
'/':begin x:=pop(s);x:=pop(s)/x; end;
end;
push(s,x);
i:=i+1;ch:=a[i];
end;
writeln(trunc(pop(s)));
end.
用pascal 运行一下注意结尾用@来结束输入

求值后缀表达式 3 5*6 7+11/ - 后缀表达式求值 c++ 后缀表达式求值算法 将中缀表达式6-8/4+3×5-(7-3)×8/(5-2)转为后缀表达式 表达式5+(9-2)*3的后缀表达式为 表达式求值中缀表达式转换为后缀表达式,并求值,(C语言) 求《数据结构》课程设计(题目:算术表达式求值)系统应具备的功能:(1)设计算术表达式的存储结构(2)实现前缀表达式、中缀表达式和后缀表达式的求值 (3)输出求值结果希望 与中缀表达式23+((12*3-2)/4+34*5/7)+108/9等价的后缀表达式为——? 6+5*(2-3/4)-3*4/2的后缀表达式 3+2*6-8/2的后缀表达式 3+2*6-8/2的后缀表达式 中缀表达式转后缀表达式7*(5-6*8)-9怎样转化成后缀表达式——————只要详细说明怎样转换就好了,不要写一段具体转换的程序上来 中缀表达式3 + 4/(25 -(6+15))* 8转换为后缀表达式 中缀表达式为:5*x-3+b/x^2 的前缀 后缀表达式分别是什么?a+b*c/d 的前缀 后缀呢? 算术表达式能实现前缀后缀和中缀的表达是求值设计表达式的存储结构能求出结果 把此中缀表达式1 + (2-3) * 4 - 10 / 5 转为后缀表达式.要准确.把此中缀表达式1 + (2-3) * 4 - 10 / 5 转为后缀表达式.要准确. 几个后缀中缀 表达式互转 的表达式: 1. 后缀转中缀 24 8 + 3 * 4 10 7 - * / @ 2. 中缀转后缀 A * B * C1. 后缀转中缀 24 8 + 3 * 4 10 7 - * / @ 2. 中缀转后缀 A * B * C C语言 表达式求值 2/5+3﹡(6-4)利用栈的定义怎么表示