链表、栈、队列的顺序存储方式为:
#define MAXSIZE 10
typedef int ElementType;
//顺序表的存储结构
typedef struct
{
ElementType data[MAXSIZE];
int length;//表示线性表的长度,初始为0,最大值为MAXSIZE
}SqList;
//栈的顺序存储
typedef struct
{
ElementType data[MAXSIZE];
int top;//栈顶指针,初始为-1,栈满为(MAXSIZE-1)
//栈空:S.top==-1; 栈满:S.top==MAXSIZE-1
}SqStack;
//队列的顺序存储
typedef struct
{
ElementType data[MAXSIZE];
int front;//头指针,若队列不空,指向队列头元素
int rear;//尾指针,若对列不空,指向队列尾元素的下一个位置
//栈空:Q.front=Q.rear 栈满:(Q.rear+1)%MAXSIZE==Q.rear
}SqQueue;
链表、栈、队列的链式存储方式为:
typedef int ElementType;
//单链表的存储结构
typedef struct LNode
{
ElementType data;
struct LNode *next;
}LNode,*LinkList;
//链栈的存储结构
typedef struct SNode
{
ElementType data;
struct SNode *next;
}SNode,*StackPtr;
typedef struct
{
stackPtr top;
int length;
}LinkStack;
//链队列的存储结构
typedef struct QNode
{
ElementType data;
struct QNode *next;
}QNode, *QueuePtr;
typedef struct
{
QueuePtr front;
QueuePtr rear;
}LinkQueue;