SWEA-계산기3(1224)


SWEA-계산기3(1224)

def CHANGE(arr): stack = [] words = '' for i in arr: if i in '(*+)': if i == ')' and stack: while stack[-1] != '(' and stack: words += stack.pop() stack.pop() continue if stack and stack[-1] == '+' and i == '*': stack.append(i) elif i == '(': stack.append(i) continue else: if stack and stack[-1] != '(': words += stack.pop() stack.append(i) else: words += i return words def cal(word): stack = [] for i in word: if i not in '*+': stack.append(i) else: if i == '*' and stack: stack.append(int(stack.p...


#1224 #python #SWEA #계산기3 #문제풀이 #알고리즘

원문링크 : SWEA-계산기3(1224)