📜  给表达式加括号的程序 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:42.191000             🧑  作者: Mango

代码示例1
def p(e):
 for o in"+-*/":
    for i,c in enumerate(e):
        if(c==o)*(0==sum([(d=="(")-(d==")")for d in e[:i]])):return"("+p(e[:i])+o+p(e[i+1:])+")"
 return e