import sys
MAX=10
front=rear=-1
queue=[0]*MAX
choice=''
while rear<MAX-1 and choice!='e':
choice=input('a 表示加入一个数值,d 表示取出一个数值 ,e 表示跳出此程序')
if choice=='a':
value=int(input('输入一个数值'))
rear+=1
queue[rear]=value
elif choice=='d':
if rear> front:
front+=1
print('取出%d'%queue[front])
queue[front]=0
else:
print('队列已空')
sys.exit(0)
else:
break
print('================================================================')
if rear==MAX-1:
print('队列已满')
elif front>=rear:
print('队列已空')
while front<rear:
front+=1
print('[%d]'%queue[front],end='')
print()
print('================================================================')
参考图解数据结构书