stack栈

A stack is a data structure that provides two stack栈 - 图1 time operations: adding an element to the top, and removing an element from the top. It is only possible to access the top element of a stack.

  1. stack<int> s;
  2. s.push(3);
  3. s.push(2);
  4. s.push(5);
  5. cout << s.top(); // 5
  6. s.pop();
  7. cout << s.top(); // 2