//最重要的是细心
#include <stdio.h>
#include <stdlib.h>
#include <cstring>
#define ElementType int
#define ERROR 1e5
typedef enum { push, pop, inject, eject, end } Operation;
typedef struct Node *PtrToNode;
struct Node
{
ElementType Element;
PtrToNode Next, Last;
};
typedef struct DequeRecord *Deque;
struct DequeRecord
{
PtrToNode Front, Rear;
};
Deque CreateDeque()
{
Deque q=(Deque)malloc(sizeof(struct DequeRecord));
q->Front=(PtrToNode)malloc(sizeof(struct Node));
q->Front->Last=NULL;
q->Rear=q->Front;//初始状态头和尾指向同一个位置
q->Rear->Next=NULL;
return q;
}
//Insert item X on the front end of deque D.
int Push( ElementType X, Deque D )
{
struct Node* tmp=(struct Node *)malloc(sizeof(struct Node));
tmp->