⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stack2.cpp

📁 hello everybody. good lucky to you
💻 CPP
字号:
// Borland C++ - (C) Copyright 1991 by Borland International

// stack2.cpp:     Implementation of the Stack class
// from Hands-on C++

#include <iostream.h>
#include "stack2.h"

int Stack::push(int elem)
{
   if (top < nmax)
   {
      list[top++] = elem;
      return 0;
   }
   else
      return -1;
}

int Stack::pop(int& elem)
{
   if (top > 0)
   {
      elem = list[--top];
      return 0;
   }
   else
      return -1;
}

void Stack::print()
{
   for (int i = top-1; i >= 0; --i)
      cout << list[i] << "\n";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -