赞
踩
// 链接存储的栈实现文件
#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* curr = ls->top;
while(curr) {
LNode* next = curr->next;
free(curr);
curr=next;
}
ls->top = NULL;
ls->len = 0;
}
/判断栈是否为空/
bool LS_IsEmpty(LinkStack* ls)
{
// 请在这里补充代码,完成本关任务
/********** Begin **
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。