用栈实现四则运算
第一部分 :LinkStack.h
#ifndef LINKSTACK_H
#define LINKSTACK_H
#include <stdlib.h>
#include <stdio.h>
#define SUCCESS 10000
#define FAILURE 10001
#define TRUE 10002
#define FALSE 10003
typedef struct StackNode
{
int data;
struct StackNode *next;
}Node;
typedef struct StackInfo
{
struct StackNode *top;
int length;
}Stack;
int InitStack(Stack **s);
int Push(Stack*s, int e);
int EmptyStack(Stack *s);
int GetTop(Stack *s);
int Pop(Stack *s);
int ClearStack(Stack *s);
int DestroyStack(Stack **s);
#endif
第二部分 :LinkStack.c
#include "LinkStack.h"
int InitStack(Stack **s)
{
if (NULL == s)
{
return FAILURE;
}
*s = (Stack *)malloc(sizeof(Stack));
if (NULL == *s)
{
return FAILURE;
}
(*s)->top = NULL;
(*s)->length = 0;
return SUCCESS;
}
int Push(Stack *