
栈
栈的实现及基本操作
心若雪
c++学习中......
展开
-
数据结构-栈(链式表示)(c++)
#include<iostream> using namespace std; //链栈实现 template<typename T> class node { public: node() { data = NULL; next = nullptr; } node(T _data) { data = _data; next = nullptr; } ~node() { if (next != nullptr) { next = nullptr; } } T data.原创 2022-05-04 18:36:45 · 200 阅读 · 0 评论 -
数据结构-栈(顺序表示)(c++)
#include<iostream> using namespace std; //顺序栈 template<typename T> class listStack { public: listStack(int _max = 10) { max = _max; L = new T[max]; length = 0; top = &L[0]; } ~listStack() { if (L != nullptr) { delete[] L; } } void pu.原创 2022-05-04 18:34:54 · 81 阅读 · 0 评论