数据结构—栈链表
首先还是简单说一下数据结构的堆栈与C语言里面的区别吧。(ps:这个在学习汇编的时候老师也讲过。忘记了,果然我还是太菜🐔了)
数据结构 | C语言 | |
---|---|---|
一种存储数据的格式 | 内存空间 | |
栈 | 满足先进后出,后进先出的原则 | 为向下增长的,栈中分配局部变量空间 |
堆 | 类似于树一样的结构,根节点的值最小或最大 | 为向上增长的,一般为申请的空间以及静态与全局变量 |
栈:在数据结构中就分为两类,线性栈和链栈,都是遵循一个原则先进后出,不能尾插,一些杂七杂八的不能用罢了,详细的还是请去琢磨书,我就简简单单的说一下了,详细的还是得直接看看书,冲冲冲🚀!详细的还是得直接看看书(Three times!)
/*
* @Description: main.c
* @Author: 小刘
* @Date: 2020-11-22 19:41:25
* @LastEditTime: 2020-11-23 14:37:23
* @LastEditors: 小刘
* @Reference:
*
*/
/*The stack is similar to the linear table, but only part of
*the linear table can be operated!
*/
#include "stacklinklist.h"
#include "stacklinklist.c"
int main(int argc, const char *argv[])
{
int i, j;
LinkStack st;
InitLinkStack(&st); // init stack memory
for (int i = 1; i <= 5; i++)
{
CerateLinkStack(&st, i); //input some element in stack list
}
printf("element");
ShowLinkStack(&st);
i