4 条题解

  • 2
    @ 2023-11-8 11:32:35
    s = input()
    st = [0]* 1000
    top = -1
    s = s.split()
    temp = 0
    
    for i in range(len(s)):
        if s[i] >= '0' and s[i] <= '9':
            top = top + 1
            st[top] = int(s[i])
        
        elif s[i] == '+':
            temp = st[top - 1] + st[top]
            top = top - 1
            st[top] = temp
        
        elif s[i] == '-':
            temp = st[top - 1] - st[top]
            top = top - 1
            st[top] = temp
        
        elif s[i] == '*':
            temp = st[top - 1]* st[top]
            top = top - 1
            st[top] = temp
        
        elif s[i] == '/':
            temp = st[top - 1]/ st[top]
            top = top - 1
            st[top] = temp
        
    print("%.2f" % st[0])
    

    信息

    ID
    796
    时间
    1000ms
    内存
    256MiB
    难度
    7
    标签
    (无)
    递交数
    1074
    已通过
    217
    上传者