10.栈和队列

只能在栈顶端进行操作,“后进先出”。
常用操作:

#include<stack>
std::stack<int> s;
s.empty();//判断是否为空
s.push(x);//插入
s.pop();//删除
s.size();//大小
s.top();//返回栈顶元素

队列
必须在队列两端进行操作,尾部插入,头部删除。
常用操作:

#include<queue>
queue<int> q;
q.empty();
q.push(x)
q.pop()
q.size()
q.front()//返回队首
q.back()//返回队尾

猜你喜欢

转载自blog.csdn.net/htt789/article/details/80866643
10.