Problem1383--双端队列

1383: 双端队列

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 0  Solved: 1
[Submit] [Status] [Web Board] [Creator:]

Description

双端队列(deque,即double-ended queue的缩写)是一种具有队列和栈性质的数据结构,即可以(也只能)在线性表的两端进行插入和删除。若以顺序存储方式实现双端队列,请编写例程实现下列操作: Push(X,D):将元素X插入到双端队列D的头; Pop(D):删除双端队列D的头元素,并返回; Inject(X,D):将元素X插入到双端队列D的尾部; Eject(D):删除双端队列D的尾部元素,并返回。 函数接口定义: bool Push( ElementType X, Deque D ); ElementType Pop( Deque D ); bool Inject( ElementType X, Deque D ); ElementType Eject( Deque D ); 其中Deque结构定义如下: typedef int Position; typedef struct QNode *PtrToQNode; struct QNode { ElementType *Data;

Input

队列Q,需要的队列元素x

Output

队列Q,需要的队列元素x

Sample Input Copy

3
Pop
Inject 1
Pop
Eject
Push 2
Push 3
Eject
Inject 4
Inject 5
Inject 6
Push 7
Pop
End

Sample Output Copy

Deque is Empty!
1 is out
Deque is Empty!
2 is out
Deque is Full!
Deque is Full!
3 is out
Inside Deque: 4 5

Source/Category