题解 | #栈和队列的实现#
栈和队列的实现
https://www.nowcoder.com/practice/ea35dab9285a44fb901b0cb1ada3f873
list_stack = [] list_queue = [] for i in range(5): num = int(input()) list_stack.append(num) list_queue.append(num) if i+1 == 2: print(list_stack) print(list_queue) list_stack.pop(-1) list_queue.pop(0) print(list_stack) print(list_queue) if i+1 == 5: print(list_stack) print(list_queue) for i in range(len(list_stack)): print(list_stack.pop(-1), end=' ')