首页 > 其他 > 详细

模板 - 栈

时间:2019-07-19 00:52:30      阅读:48      评论:0      收藏:0      [点我收藏+]

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;
    }
};

模板 - 栈

原文:https://www.cnblogs.com/Yinku/p/11210635.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!