#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define N 5
typedef struct s //队节点
{
char c[8];
struct s *next;
}ss;
typedef struct //指针节点
{
ss *front;
ss *rear;
}queue;
typedef struct //栈节点
{
char data[N][8];
int top;
}stack;
stack *init1(stack *s)
{
s=(stack*)malloc(sizeof(stack));
s->top=-1;
return s;
}
void push(stack *s,char m[]) //入栈
{
s->top=s->top+1;
strcpy(s->data[s->top],m);
}
char *pop(stack *s) //出栈
{
return (s->data[s->top--]);
}
void init2(queue *Q) //初始化队列
{
ss *node;
node = (ss*)malloc(sizeof(ss)); //分配一个头节点
node->next = NULL;
Q->front=Q->rear=node; //分配一个头节点,头节点里啥也没有
}
void enqueue(queue *Q , char m[]) //入队
{
ss *node;
node = (ss*)malloc(sizeof(ss));
strcpy(node->c,m);
node->next = NULL;
Q->rear->next =
#include<stdlib.h>
#include<string.h>
#define N 5
typedef struct s //队节点
{
char c[8];
struct s *next;
}ss;
typedef struct //指针节点
{
ss *front;
ss *rear;
}queue;
typedef struct //栈节点
{
char data[N][8];
int top;
}stack;
stack *init1(stack *s)
{
s=(stack*)malloc(sizeof(stack));
s->top=-1;
return s;
}
void push(stack *s,char m[]) //入栈
{
s->top=s->top+1;
strcpy(s->data[s->top],m);
}
char *pop(stack *s) //出栈
{
return (s->data[s->top--]);
}
void init2(queue *Q) //初始化队列
{
ss *node;
node = (ss*)malloc(sizeof(ss)); //分配一个头节点
node->next = NULL;
Q->front=Q->rear=node; //分配一个头节点,头节点里啥也没有
}
void enqueue(queue *Q , char m[]) //入队
{
ss *node;
node = (ss*)malloc(sizeof(ss));
strcpy(node->c,m);
node->next = NULL;
Q->rear->next =