1 template <typename T>
2 struct Stack{//自建栈
3 T *item;
4 int capacity;
5 int top;
6 Stack(int c = 1000)
7 {
8 capacity = c;
9 item = new T[capacity];
10 top =0;
11 }
12 ~Stack(){
13 capacity = 0;
14 top = 0;
15 delete [] item;
16 }
17 void push(const T &e)
18 {
19 if(top == capacity)
20 {
21 cout<<"栈满,栈溢出!"<<endl;
22 }
23 else{
24 item[top++] = e;
25 }
26 }
27 T& pop()
28 {
29 if(top==0){
30 cout<<"栈空"<<endl;
31 }
32 else{
33 return item[--top];
34 }
35 }
36 T& Top()
37 {
38 return item[top-1];
39 }
40 bool Empty()
41 {
42 if(top==0)return true;
43 return false;
44 }
45 };
你的脸上风淡云轻,谁也不知道你的牙咬得有多紧。你走路带着风,谁也不知道你膝盖上仍有曾摔过的伤的淤青。你笑得没心没肺,没人知道你哭起来只能无声落泪。要让人觉得毫不费力,只能背后极其努力。我们没有改变不了的未来,只有不想改变的过去。