附录 源代码 1. 头文件 Car.h #ifndef CAR #define CAR #include using namespace std; typedef struct Node { void *data; struct Node *link; }nodeS; typedef struct Sta { nodeS *top; int count; }Stack; typedef struct NodeQ { void *dataptr; struct NodeQ *next; }nodeQ; typedef struct Queues { int count; nodeQ *front; nodeQ *rear; }Que; Stack *Createstack(); void* pop(Stack *stack); void push(Stack *stack,void *data); void DestroyStack(Stack *stack); Que *CreateQueue(); void Enqueue(Que *queue); void *Dequeue(Que *queue); void Destroyqueue(Que *queue); #endif 2. 实现文件Car.cpp #include "Car.h" Stack *Createstack() { Stack *stack; stack = new Stack; if(stack == NULL) return NULL; stack->count = 0; stack->top = NULL; return stack; } void push(Stack *stack,void *data) { nodeS *node; node = new nodeS; if(node == NULL || stack == NULL) return ; node->data = data; node->link = stack->top; stack->top = node; stack->count++; } void* pop(Stack *stack) { void *data; nodeS *node; node = new nodeS; if(stack->count == 0) return NULL; data = stack->top->data; node = stack->top; stack->top = node->link; stack->count--; return data; } void DestroyStack(Stack *stack) { nodeS *node; if(stack->count == 0) return ; while(stack->count == 0) { delete stack->top->data; node = stack->top; stack->top = node->link; stack->count--; } delete stack; } Que *CreateQueue() { Que *queue; queue = new Que; if(queue == NULL) return NULL; queue->count = 0; queue->front = NULL; queue->rear = NULL; return queue; } void Enqueue(Que *queue) { nodeQ *node; node = new nodeQ; if(node == NULL || queue == NULL) return ; node->next = NULL; if(queue->count == 0) { queue->front = node; }else { queue->rear->next = node; } queue->rear = node; queue->count++;...