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

📄 linkedstack.cpp

📁 datastucutre and algorithms, application, in C
💻 CPP
字号:
// test linked stack

#include <iostream>
#include "linkedStack.h"
#include "myExceptions.h"

using namespace std;

int main(void)
{
   linkedStack<int> s;

   // add a few elements
   s.push(1);
   s.push(2);
   s.push(3);
   s.push(4);

   cout << "Stack should be 1234, bottom to top" << endl;

   // test empty and size
   if (s.empty())
      cout << "The stack is empty" << endl;
   else
      cout << "The stack is not empty" << endl;

   cout << "The stack size is " << s.size() << endl;

   while (!s.empty())
   {
      cout << "Stack top is " << s.top() << endl;
      s.pop();
      cout << "Popped top element" << endl;
   }

   try {s.pop();}
   catch (stackEmpty message)
   {
      cout << "Last pop failed " << endl;
      message.outputMessage();
   }

   return 0;
}

⌨️ 快捷键说明

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