模板 - 栈

STL的栈,可能有一些不需要的信息。
其实用数组实现之后是这个鬼样子。感觉还不如直接用。

struct Stack{
    int st[MAXSIZE];
    int top;
    inline void Clear(){
        top=0;
    }
    inline void Push(int x){
        st[++top]=x;
    }
    inline void Pop(){
        --top;
    }
    inline int Top(){
        return st[top];
    }
    inline int Size(){
        return top;
    }
    inline bool Empty(){
        return !top;
    }
};
posted @ 2019-07-18 23:03  韵意  阅读(151)  评论(0编辑  收藏  举报