program bds;
const m=50;
type {定义栈}
stack=array[1..m] of char;
stack1=array[1..m] of real;
var
s:stack;
s1:stack1;
e,a:string;
i,l,p,y:integer;
x:real;
begin
{中缀表达式e转后缀表达式a, s为运算符栈,P为指针}
read(e);{读入一个中缀表达式}
p:=0;
l:=length(e);
for i:=1 to l do
begin
case e[i] of
'0'..'9':a:=a+e[i]; {若为数字,进入后缀表达式}
'(':begin p:=p+1;s[p]:='('; end;{若为左括号,进栈}
')':begin {若为右括号,则左括号前的所有运算符出栈进入后缀表达式,)舍}
while s[p]<>'(' do
begin
a:=a+s[p];p:=p-1;
end;
p:=p-1;
end;
'+','-':begin{若为+-号,则左括号前的所有运算符出栈进入后缀表达式,+-号进栈}
while (s[p]<>'(') and (p<>0) do
begin a:=a+s[p];p:=p-1;end;
p:=p+1;s[p]:=e[i];
end;
'*','/':begin {若为*/号,则左括号前的栈顶的*/出栈进入后缀表达式,*/号进栈}
while (p<>0) and ((s[p]='*') or (s[p]='/')) do
begin
a:=a+s[p];p:=p-1;
end;
p:=p+1; s[p]:=e[i];
end;
end;{case}
end;{for}
while p<>0 do {所有运算符出栈进入后缀表达式}
begin
a:=a+s[p];p:=p-1;
end;
writeln(a);
{ 计算后缀表达a的值,S1为存放操作数的栈,P为栈指针}
l:=length(a); p:=0;
for i:=1 to l do
begin
case a[i] of
'0'..'9':begin {是操作数,将操作数转为数值类型数据后进栈}
p:=p+1; val(a[i],x,y); s1[p]:=x;
end;
'+':begin {栈顶的两个操作数出栈,进行加法运算,其结果进栈}
x:=s1[p];p:=p-1; s1[p]:=s1[p]+x;
end;
'-':begin {栈顶的两个操作数出栈,进行减法运算,其结果进栈}
x:=s1[p];p:=p-1; s1[p]:=s1[p]-x;
end;
'*':begin {栈顶的两个操作数出栈,进行乘法运算,其结果进栈}
x:=s1[p];p:=p-1; s1[p]:=s1[p]*x;
end;
'/':begin {栈顶的两个操作数出栈,进行除法运算,其结果进栈}
x:=s1[p];p:=p-1; s1[p]:=s1[p]/x;
end;
end;{case}
end;{for}
writeln(s1[p]:5:2); {栈底的结果为最终运算结果}
end.