顺序反了就错了
运行下面这段程序——注意减法两个数的先后:
st = []
for t in ["5", "1", "-"]:
if t == "-":
b = st.pop()
a = st.pop()
st.append(a - b)
else:
st.append(int(t))
print(st.pop())
运行下面这段程序——注意减法两个数的先后:
st = []
for t in ["5", "1", "-"]:
if t == "-":
b = st.pop()
a = st.pop()
st.append(a - b)
else:
st.append(int(t))
print(st.pop())
全部评论