diff --git a/codes/cpp/chapter_stack_and_queue/stack.cpp b/codes/cpp/chapter_stack_and_queue/stack.cpp index 03cac3c5a..09fcb485f 100644 --- a/codes/cpp/chapter_stack_and_queue/stack.cpp +++ b/codes/cpp/chapter_stack_and_queue/stack.cpp @@ -6,3 +6,33 @@ #include "../include/include.hpp" +int main(){ + /* 初始化栈 */ + stack stack; + + /* 元素入栈 */ + stack.push(1); + stack.push(3); + stack.push(2); + stack.push(5); + stack.push(4); + cout<<"栈 stack = "; + PrintUtil::printStack(stack); + + /* 访问栈顶元素 */ + int top = stack.top(); + cout<<"栈顶元素 top = "<