//-----------链式堆栈实现------------------- // // 实现的为 带头节点的链式堆栈 // // //------------2010年9月27日 17:32:42-------- By AndGod #include "stdio.h" #include "malloc.h" typedef int DataType ; //定义堆栈存储数据类型 typedef struct snode //定义链式堆栈节点 { DataType data; struct snode *next; }LSNode; void StackInitiate(LSNode **head) { //初始化带头节点的 链式堆栈 *head=(LSNode *)(malloc(sizeof(LSNode))); (*head)->next=NULL; } int StackIsEmpty(LSNode *head) { //判断链式堆栈是否为空 --空则返回1,非空则返回0 if(head->next == NULL) { return 1; } else { return 0; } } void StackPush(LSNode *head,DataType x) { //进栈------------ LSNode *p; p=(LSNode*)malloc(sizeof(LSNode)); p->data=x; p->next=head->next; head->next=p; } int StackPop(LSNode *head,DataType *x) { //出栈, 元素由x带出,成功返回 1 失败返回0 if(StackIsEmpty(head)) { return 0; } else { *x=(head