1. The use 数组of a data structure that implements a stack requires the following methods:
Push the stack: insert elements at the top of the stack
Bouncing stack: pop the top element of the stack
Get the top element of the stack
Determine if the stack is empty
Get the number of elements in the stack
2. Stack operation
Create a new stack (named s1)
Push the array ls_1 from small to large by index
Number of elements in the output stack
Get the top element of the stack, save it in the variable s1_gettop, and observe the number of elements in the stack
Pop the top element of the stack, save it in the variable s1_poptop, and observe the number of elements in the stack
prompt
1. Stack
Introduction
A commonly used data structure
LIFO-last in first out: the last inserted element comes out first
Note:
Getting the top element of the stack does not change the stack itself
Popping the top element of the stack is based on obtaining the top element of the stack, and then performing a stack operation to change the stack. You can use the popmethods in the list