mirror of
https://github.com/krahets/hello-algo.git
synced 2025-07-05 21:19:41 +08:00
Update the structure of the chapter
of binary tree.
This commit is contained in:
@ -41,13 +41,6 @@ public:
|
||||
return stack.back();
|
||||
}
|
||||
|
||||
/* 访问索引 index 处元素 */
|
||||
int get(int index) {
|
||||
if(index >= size())
|
||||
throw out_of_range("索引越界");
|
||||
return stack[index];
|
||||
}
|
||||
|
||||
/* 返回 Vector */
|
||||
vector<int> toVector() {
|
||||
return stack;
|
||||
@ -73,10 +66,6 @@ int main() {
|
||||
int top = stack->top();
|
||||
cout << "栈顶元素 top = " << top << endl;
|
||||
|
||||
/* 访问索引 index 处元素 */
|
||||
int num = stack->get(3);
|
||||
cout << "栈索引 3 处的元素为 num = " << num << endl;
|
||||
|
||||
/* 元素出栈 */
|
||||
int pop = stack->pop();
|
||||
cout << "出栈元素 pop = " << pop << ",出栈后 stack = ";
|
||||
|
Reference in New Issue
Block a user