栈、队列的相关知识点

来源:互联网 发布:方维网络 编辑:程序博客网 时间:2024/05/21 17:38

头文件:#include<stack>   #include<queue>

栈和队列的定义:如stack<int> s;     queue<char> q;

入栈/队列   s.push(x);

出栈/队列   s.pop();

返回栈/队列的数据数量  s.size();

判断栈/队列是否为空   s.empty();  空的话返回true

返回栈顶元素  s.top();

返回队列头部元素  q.front();

返回队列尾部元素  q.back();

0 0