本文主要是介绍栈讲解 洛谷P4387 【深基15.习9】验证栈序列,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
验证栈序列
洛谷P4387
Hello~ 今天我们来看一下栈!
首先 栈是啥?
简单来说 可以理解成一个桶 先进后出(LIFO) 像这样
(图片源自网络)
(https://i.stack.imgur.com/jLlQz.png)
一些基本的function在这里:
empty
Test whether container is empty (public member function )
size
Return size (public member function )
top
Access next element (public member function )
push
Insert element (public member function )
emplace
Construct and insert element (public member function )
pop
Remove top element (public member function )
swap
Swap contents (public member function )
在这里简单展示4个最常用的
#include <iostream>
#include <stack> // Don't forget!
using namespace std;
stack<int> s; // Important!
int main ()
{int a;cin >> a;s.push(
这篇关于栈讲解 洛谷P4387 【深基15.习9】验证栈序列的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!