1 // Stack.cpp : 定义控制台应用程序的入口点。 2 // 3 4 #include "stdafx.h" 5 #include 6 using namespace std; 7 8 template 9 struct Stack10 {11 private:12 Type *_stack;13 int _top;14 int _min;15 int _size;16 17 18 public:19 Stack(const Type &size):_size(size),_top(0),_min(0)20 { 21 _stack = new Type[size];//(Type*)malloc(sizeof())22 }23 void push(const Type &value)24 {25 26 if(_top == 0)27 {28 _min = value;29 }30 else if(_top == _size)31 {32 cout<<"Push failed,the stack is full"<
sk(30);71 sk.push(8);72 sk.push(7);73 sk.push(6);74 sk.push(5);75 sk.push(9);76 sk.push(4);77 sk.push(3);78 79 cout<