描述 Description
给定一个表达式串,计算其最后结果
输入格式 Input Format
一个表达式串(只包函+-*/()等运算符,且是整除;表达式长度小于255个字符)
输出格式 Output Format
最后结果(一个整数)
样例输入
1+2*3+(1+2)
样例输出
10
program p1654;
var tot:ansistring;
function f(st:ansistring):longint;
var i,len,khw,ans,n,m:longint;
fh:boolean;
begin
if st='' then exit (0);
n:=520;
len:=length(st);
fh:=false;
ans:=0;
for i:=1 to len do
if st[i]in['+','-','*','/'] then fh:=true;
if not fh then begin val(st,ans);exit(ans);end;
khw:=0;
for i:=len downto 1 do
begin
if st[i] =')' then inc(khw);
if st[i] ='(' then dec(khw);
if khw=0 then
begin
if st[i]in['+','-','*','/'] then
begin
case st[i] of
'+':begin n:=1;m:=i;end;
'-':if n<>1 then begin n:=2;m:=i;end;
'*':if not(n in[1,2]) then begin n:=3;m:=i;end;
'/':if not(n in[1,2,3]) then begin n:=4;m:=i;end;
end;
case n of
1:exit(f(copy(st,1,m-1))+f(copy(st,m+1,length(st)-m)));
2:exit(f(copy(st,1,m-1))-f(copy(st,m+1,length(st)-m)));
3:exit(f(copy(st,1,m-1))*f(copy(st,m+1,length(st)-m)));
4:exit(f(copy(st,1,m-1))div f(copy(st,m+1,length(st)-m)));
end;
end;
end;
end;
if n=520 then exit (f(copy(st,2,len-2)));
end;
begin
readln(tot);
writeln(f(tot));
// readln(tot);
end.