题解 | #【模板】栈#
【模板】栈
https://www.nowcoder.com/practice/104ce248c2f04cfb986b92d0548cccbf
from re import X n=int(input()) z=[] for i in range(n): do=input() if do.startswith("push"): x=do.split() z.append(int(x[1])) elif do=="pop": if z==[]: print("error") else: zp=z.pop() print(zp) elif do=="top": if z==[]: print("error") else: print(z[-1])