zoukankan      html  css  js  c++  java
  • 团队-象棋游戏-模块开发过程

    def calculate(expression):
    ex=[]
    ans=0
    if '(' not in expression:
    ans=fun(expression)
    return ans
    for i in range(len(expression)):
    if expression[i]=='(':
    ex.append(i) 
    elif expression[i]==')': 
    temp=0
    sub=expression[ex[len(ex)-1]+1:i]
    temp=fun(sub)
    expression=expression[0:ex[len(ex)-1]]+str(temp)+expression[i+1:len(expression)+1]
    ex.pop()
    return calculate(expression)

    s='1 - 2 * ( (60-30 +(-40/5+3) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) )'

    print(1 - 2 * ( (60-30 +(-40/5+3) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) - (-4*3)/ (16-3*2) ))
    s3='3*(4+50)-((100+40)*5/2-3*2*2/4+9)*(((3+4)-4)-4)'                
    print(3*(4+50)-((100+40)*5/2-3*2*2/4+9)*(((3+4)-4)-4))
    print(calculate(s))                                                
    print(calculate(s3))

  • 相关阅读:
    poj 2996 模拟
    poj 2965 BFS
    poj 1068 模拟
    poj 3295 前缀表达式求值
    常用的十七大学术搜索引擎
    Why,Unix or Linux ?
    匈牙利命名法
    微调控件(CSpinButtonCtrl)
    美国免费邮箱
    ASP常用的代码
  • 原文地址:https://www.cnblogs.com/yl1234/p/7777321.html
Copyright © 2011-2022 走看看