//队列一段插入另一端删除,队尾插入,队头删除
//push()入队 pop()出队 back()队尾 front()对头
//不能进行遍历,不支持迭代器,不支持随机访问
# include <iostream>
# include <queue>
using namespace std;
void test01()
{
queue<int> q;//创建队列
q.push(10);
q.push(20);
q.push(30);
q.push(40);
q.push(50);
cout << "队尾: " << q.back() << endl;
cout << "对头: " << q.front() << endl;
//输出顺序
while(!q.empty())
{
cout << q.front() << " ";//输出对头元素
q.pop();
}
cout << endl;
}
int main(int argc, char *argv[])
{
test01();
return 0;
}
//push()入队 pop()出队 back()队尾 front()对头
//不能进行遍历,不支持迭代器,不支持随机访问
# include <iostream>
# include <queue>
using namespace std;
void test01()
{
queue<int> q;//创建队列
q.push(10);
q.push(20);
q.push(30);
q.push(40);
q.push(50);
cout << "队尾: " << q.back() << endl;
cout << "对头: " << q.front() << endl;
//输出顺序
while(!q.empty())
{
cout << q.front() << " ";//输出对头元素
q.pop();
}
cout << endl;
}
int main(int argc, char *argv[])
{
test01();
return 0;
}