基于Python语言的逆波兰式简易计算器

import math

# merge
def merge(arg):
    # merge the deciaml
    while (True):
        try:
            x=arg.index('.')
        except:
            break
        arg[x-1]+=arg[x]
        arg[x-1]+=arg[x+1]
        del arg[x]
        del arg[x]

    # combined trigonometric function
    while True:
        try:x=arg.index('i')
        except:
            break
        arg[x-1]+=arg[x]
        arg[x-1]+=arg[x+1]
        del arg[x]
        del arg[x]

    while True:
        try:x=arg.index('o')
        except:
            break
        arg[x-1]+=arg[x]
        arg[x-1]+=arg[x+1]
        del arg[x]
        del arg[x]

    while True:
        try:x=arg.index('a')
        except:
            break
        arg[x-1]+=arg[x]
        arg[x-1]+=arg[x+1]
        del arg[x]
        del arg[x]

    while True:
        try:x=arg.index('q')
        except:
            break
        arg[x-1]+=arg[x]
        arg[x-1]+=arg[x+1]
        arg[x-1]+=arg[x+2]
        del arg[x]
        del arg[x]
        del arg[x]
    # combined multidigit
    y=len(arg)
    i=1
    while (iPri[top1]:
                    Stack1.append(z)
                else:
                    while(1):
                        if Pri[z]>Pri[top1]:
                            break
                        Stack2.append(top1)
                        Stack1.pop()
                        if len(Stack1)==0:
                            break
                        top1=Stack1[-1]
                    Stack1.append(z)
        else:
            Stack2.append(z)

    while(len(Stack1)!=0):
        Stack2.append(Stack1.pop())

    RPN=Stack2
    return RPN



#Calculate the value of the Reverse Polish Notation
def process_RPN(RPN):
    if len(RPN)==0:
        return 0
    if len(RPN)==1:
        return RPN[0]

    p=len(RPN)
    w=0
    while w


你可能感兴趣的:(基于Python语言的逆波兰式简易计算器)