#include<iostream>
#include<queue>
using namespace std;
void test01(){
queue<int> q1;
queue<int> q2(q1);
q1.push(1);
q1.push(2);
q1.push(3);
q1.push(4);
cout<<"队的大小为:"<<q1.size()<<endl;
cout<<"队尾元素为:"<<q1.back()<<endl;
//删除队头元素
q1.pop();
//打印队里的元素
while(q1.size()>0){
cout<<q1.front()<<" ";
q1.pop();
}
cout<<endl;
cout<<"队列的大小为:"<<q1.size()<<endl;
}
int main(){
test01();
return 0;
}
【STL】10 queue容器操作
最新推荐文章于 2022-12-21 15:21:41 发布