#!/usr/bin/env python
import re
def f1(arg): return 1 origin = "1 - 2 * ( ( 60 - 30 + ( -40.0 / 5 ) * ( 9 - 2 * 5 / 3 + 7 / 3 * 99 / 4 * 2998 + 10 * 568 / 14 )) - ( - 4 * 3 ) / ( 16 - 3 * 2))"
print(eval(origin))
while True:
print(origin)
ret = re.split("\(([^()]+)\)", origin,1)
if len(ret) == 3:
before = ret[0]
content = ret[1]
after = ret[2]
r = f1(content)
new_str = before + str(r) + after
origin = new_str
else:
final = f1(origin)
print(final)
break
05-25 15:39