数据结构 简单的栈

时间:2015-05-22 05:49:12
【文件属性】:
文件名称:数据结构 简单的栈
文件大小:1KB
文件格式:TXT
更新时间:2015-05-22 05:49:12
C++栈 c++实现栈简单功能小程序 #include using namespace std; class stack { private: int a[5]; //栈的大小 int n; //记录数组的下标 int t; //头指针? public: stack(); //构造函数 int push(int); //进栈 int show(); //出栈 bool empty(); //是否为空 bool full(); //是否为栈满 int display(); //输出 ~stack(); }; stack::stack() { n=0; //初始化 t=-1; } bool stack::empty() { if(t==-1) { return true; } else return false; } bool stack::full() { if(n>=5) return true; else return false; } int stack:: push(int m) { if(!full()) { a[n]=m; cout<<"a["<=0;i--) cout< 立即下载

网友评论