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