第二章--实现一个链接存储的栈
/*************************************************************
date: June 2017
copyright: Zhu En(祝恩)
DO NOT distribute this code.
**************************************************************/
// 链接存储的栈实现文件
#include <stdio.h>
#include <stdlib.h>
#include "LnkStack.h"
/*创建栈*/
LinkStack* LS_Create()
{
LinkStack* ls=(LinkStack*)malloc(sizeof(LinkStack));
ls->top = NULL;
ls->len = 0;
return ls;
}
/*释放栈*/
void LS_Free(LinkStack* ls)
{
LNode* curr = ls->top;
while(curr) {
LNode* next = curr->next;
free(curr);
curr=next;
}
free(ls);
}
/*将栈变为空栈*/
void LS_MakeEmpty(LinkStack* ls)
{
LNode*