folstfolst
全部博文(64)
2010年(64)
Phyllis6
分类: C/C++
2010-01-26 14:07:35
//key code class Stack{ public: Stack(int); bool IsEmpty(){ return top==-1; } void Push(int key); void Pop(int& key); void Output(); private: int* data; int top; int max_size; }; Stack::Stack(int n = 100){ data = new int[n]; top = -1; max_size = n; } void Stack::Push(int key){ if(top==max_size-1) return; data[++top] = key; } void Stack::Pop(int& key){ if(IsEmpty() ) return; key = data[top--]; } void Stack::Output(){ for(int i=0;i<=top;i++) cout<<data[i]<<" "; } //key code
上一篇:功能比较完整的BST
下一篇:表达式求值
登录 注册