题解 | #【模板】循环队列#
【模板】循环队列
https://www.nowcoder.com/practice/0a3a216e50004d8bb5da43ad38bcfcbf
nums = input().split() size = int(nums[0]) # 输入空间大小 n = int(nums[1]) # 输入操作次数 queue = [] # 队列 for _ in range(n): op = input().split() # 分割操作字符串 if op[0] == "push": if len(queue) < size: queue.append(int(op[1])) # 加入队尾 else: print("full") elif op[0] == "pop": if not queue: print("empty") else: print(queue.pop(0)) # 输出队首(出队) elif op[0] == "front": if not queue: print("empty") else: print(queue[0]) # 输出队首(不出队)