Python 队里 list的常规操作, pop(0)第一个元素出栈, pop(-1)最后一个元素出栈, remove(3)删除list中值等于3的元素, insert(index, value),在index的位置,插入value
HJ48 从单向链表中删除指定值的节点
ip = list(map(int,input().split()))
total = ip.pop(0)
head = ip.pop(0)
delete = ip.pop(-1)
idata = ip
res = [head]
for i in range(0,len(idata),2):
value = idata[i]
index = res.index(idata[i+1])+1
res.insert(index, value)
res.remove(delete)
print(*res)