数据结构——栈和队列
东呱QAQ
纯小白,努力学习ing
展开
-
【数据结构——栈和队列】链队的基本操作
typedef struct QNode{ int data; //数据域 struct QNode *next; //指针域 }QNode; typedef struct{ QNode *front; //队头指针 QNode *rear; //队尾指针 }LiQueue; //初始化 void initQueue(LiQueue *&lqu){ lqu = (LiQueue *)malloc(sizeof(LiQueue)); lqu->front = lqu-&g原创 2021-12-09 20:00:56 · 347 阅读 · 2 评论 -
【数据结构——栈和队列】顺序队列的基本操作
typedef struct{ int data[maxSize]; int front; //队首指针 int rear; //队尾指针 }SqQueue; //初始化 void initQueue(SqQueue &qu){ qu.front = qu.rear = 0; } //判断队空 int isQueueEmpty(SqQueue qu){ return qu.front == qu.rear; } //入队 int enQueue(SqQueue &qu原创 2021-12-09 18:52:46 · 107 阅读 · 0 评论 -
【数据结构——栈和队列】链栈的基本操作
typedef struct LNode{ int data; struct LNode *next; }LNode; //链栈的初始化 void initStack(LNode *&lst){ lst = (LNode *)malloc(sizeof(LNode)); lst->next = NULL; //结点申请后一定要指向空 } //判断栈空 int isEmpty(LNode *lst){ return lst->next = NULL; } //进栈 voi原创 2021-12-09 18:42:41 · 90 阅读 · 0 评论 -
【数据结构——栈和队列】顺序栈的基本操作
typedef struct SqStack{ int data[maxSize]; int top; }SqStack; //顺序栈的初始化 void initStack(SqStack &st){ st.top = -1; } //判断栈空 int isEmpty(SqStack st){ return st.top == -1; } //进栈 int push(SqStack &st, int x){ if(st.top == maxSize) return 0;原创 2021-12-09 18:25:32 · 86 阅读 · 0 评论 -
【数据结构——栈和队列】结构体定义
(1)顺序栈的定义 typedef struct SqStack{ int data[maxSize]; int top; }SqStack; (2)链栈的定义 typedef struct LNode{ int data; struct LNode *next; }LNode; (3)顺序队列的定义 typedef struct{ int data[maxSize]; int front; //队首指针 int rear; //队尾指针 }SqQueue; (4)链队定义 1)原创 2021-12-09 18:05:23 · 817 阅读 · 0 评论