手写stack[加强版]

来源:互联网 发布:matlab元胞转化为矩阵 编辑:程序博客网 时间:2024/05/01 17:51
#include<bits/stdc++.h>using namespace std;class stac{    public:        void push(int x){            a.push_back(x);            len++;        }        void pop(){            len--;            a.pop_back();        }        int top(){            return a[len-1];        }        int size(){            return len;        }        bool empty(){            return len==0;        }        void swap(stac x,stac y){            stac *x1,*x2;            x1=&y;            x2=&x;            stac *x3;            x3=x1;            x1=x2;            x2=x3;        }    private:        int len;        vector<int>a;}
1 0
原创粉丝点击