#includeusing namespace std; #define MAXSIZE 50 typedef int QueueElementType; typedef struct { QueueElementType elem[MAXSIZE]; int front; //指向當前隊頭元素 int rear; //指向隊尾元素的下一個位置 }SeqQueue; void InitQueue(SeqQueue &Q); void InputQueue(SeqQueue &Q); bool EnterQueue(SeqQueue &Q,QueueElementType x); QueueElementType DeleteQueue(SeqQueue &Q); QueueElementType BackQueue(SeqQueue Q);//返回隊尾元素 bool IsFull(SeqQueue Q); bool IsEmpty(SeqQueue Q); void OutputQueue(SeqQueue Q); int QueueLength(SeqQueue Q); int main() { int x; SeqQueue q; InitQueue(q); InputQueue(q); x = BackQueue(q); cout<<"隊尾元素為:"< >m; while(m!=-1) { if(IsFull(Q)) cout<<"當前隊列已滿,無法插入"< >m; } } } bool EnterQueue(SeqQueue &Q,QueueElementType x) { if((Q.rear+1)%MAXSIZE == Q.front) return false; Q.elem[Q.rear] = x; Q.rear = (Q.rear+1)%MAXSIZE; return true; } QueueElementType DeleteQueue(SeqQueue &Q) { if(IsEmpty(Q)) { cout<<"當前隊列為空,出隊列失敗!"<