zoukankan      html  css  js  c++  java
  • CC++编程中:相对路径+绝对路径 CStack栈模板封装示例

    CC++编程中:相对路径+绝对路径

     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 };
    你的脸上风淡云轻,谁也不知道你的牙咬得有多紧。你走路带着风,谁也不知道你膝盖上仍有曾摔过的伤的淤青。你笑得没心没肺,没人知道你哭起来只能无声落泪。要让人觉得毫不费力,只能背后极其努力。我们没有改变不了的未来,只有不想改变的过去。
  • 相关阅读:
    关于网页代码加密解密保护,保障页面安全
    DS--知识积累
    知识积累
    Nested DollsHDU1677
    CF335B
    HDU2385Stock
    滚动数组处理数据很大的公共子序列问题
    HDU4635
    HDU4638
    HDU4639
  • 原文地址:https://www.cnblogs.com/wangzhe52xia/p/12599680.html
Copyright © 2011-2022 走看看