12345678910111213141516171819202122232425262728293031323334 |
- def toList(s):
- L = []
- for i in s:
- if i != '\n':
- L.append(i)
- return L
- def f(i,s,S = None):
-
- if not S:
- S = []
-
- if i == len(s):
- return S[0]
- a = s[i]
- if a.isdigit():
- S.append(a)
- return f(i+1,s,S)
- else:
- c = S.pop()
- d = S.pop()
- e = '%s%s%s'%(c,a,d)
- S.append(eval(e))
- return f(i+1,s,S)
- x = raw_input()
- s = ""
- while x != '=\n':
- s += x
- x = raw_input() + '\n'
- print f(0,toList(s))
|