Advertisement

链栈实现表达式求值(栈版本)

阅读量:

头文件:

复制代码
    /***链栈实现表达式求值***/
    
    #include<iostream>
    using namespace std;
    
    const char oper[7] = { '+', '-', '*', '/', '(', ')', '#' };
    #define OK 1
    #define ERROR 0
    #define OVERFLOW -2
    typedef char SElemType;
    typedef int Status;
    typedef struct SNode {
    	int data;
    	struct SNode *next;
    } SNode, *LinkStack;
    
    Status InitStack(LinkStack &S) {
    	S = NULL;
    	return OK;
    }
    bool StackEmpty(LinkStack S) {
    	if (!S)
    		return true;
    	return false;
    }
    Status Push(LinkStack &S, SElemType e) {
    	SNode *p = new SNode

全部评论 (0)

还没有任何评论哟~