C++ queue
来源:互联网 发布:java class命名 编辑:程序博客网 时间:2024/06/05 21:59
/*
队列:FIFO 先进先出
自适应器(容器适配器)
栈适配器 STL queue
queue<int,deque<int>> q;
queue<int,list<int>> q;
q.empty();
q.size();
q.front();
q.back();
q.pop();
q.push();
*/
#include<iostream>
#include<queue>
#include<deque>
#include<list>
using namespace std;
int main(){
queue<int,deque<int>> a;
queue<int,list<int>> b;
queue<int> q;
q.push(10);
q.push(5);
q.push(-1);
q.push(20);
q.push(30);
q.push(40);
q.push(50);
cout<<"现在队列里有"<<q.size()<<"个数据"<<endl;
cout<<"队首的数据是"<<q.front()<<endl;
cout<<"队尾的数据是"<<q.back()<<endl;
q.pop();
cout<<"pop以后,新队首的数据:"<<q.front();
while(q.size()!=0)
{
cout<<q.front()<<endl;
q.pop();
}
if(q.empty())
{cout<<"此队列是空的"<<endl;}
return 0;
}
队列:FIFO 先进先出
自适应器(容器适配器)
栈适配器 STL queue
queue<int,deque<int>> q;
queue<int,list<int>> q;
q.empty();
q.size();
q.front();
q.back();
q.pop();
q.push();
*/
#include<iostream>
#include<queue>
#include<deque>
#include<list>
using namespace std;
int main(){
queue<int,deque<int>> a;
queue<int,list<int>> b;
queue<int> q;
q.push(10);
q.push(5);
q.push(-1);
q.push(20);
q.push(30);
q.push(40);
q.push(50);
cout<<"现在队列里有"<<q.size()<<"个数据"<<endl;
cout<<"队首的数据是"<<q.front()<<endl;
cout<<"队尾的数据是"<<q.back()<<endl;
q.pop();
cout<<"pop以后,新队首的数据:"<<q.front();
while(q.size()!=0)
{
cout<<q.front()<<endl;
q.pop();
}
if(q.empty())
{cout<<"此队列是空的"<<endl;}
return 0;
}
1 0
- queue.c
- queue.c
- c-queue?
- C/C++-----------00queue-------
- Queue-C++template1
- Queue-C++template
- Queue-c数组
- queue-c链式队列
- #include<queue> 【c++】
- c++queue容器介绍
- freeBSD queue.c--定时器
- [C++] Stack / queue / priority_queue
- QUEUE C语言实现
- #include<queue> 【c++】
- c++stack,queue
- c++queue容器介绍
- C++_队列(Queue)
- [c]队列queue
- java 排序算法
- Linux守护进程
- 带分数(dfs)
- centos6.5 lamp+gogs环境搭建
- sdutacm-最长上升子序列
- C++ queue
- Leetcode 363. Max Sum of Rectangle No Larger Than K
- Linux系统smbclient命令的使用方法(RaspberryPi)
- HTTP协议响应(详解)
- python 中的深拷贝和浅拷贝
- 0001_20170226_【我是菜鸟】_【Java】_Java Character类
- 程序员必读书籍及导读指南
- 类和继承
- Spring HibernateTemplate详解