1.queue<int> a;使a成为队列
2.a.push();入队
例子:int n;
cin>>n;
a.push(n);
3.a.pop();出队
4.a.front();返回队首元素-----与之对应a.back();返回队尾元素
例子:
#include<bits/stdc++.h>
using namespace std;
int main(){
queue<int>a;
int n,b;
cin>>n;
for(int i=0;i<n;i++){
cin>>b;
a.push(b);
}
cout<<a.front();
return 0;
}
5.a.empty();若为空返回1,若不为空返回0
例子:
if(a.empty()==0){
cout<<"队列a不为空";
}
if(a.empty()==1){
cout<<"队列a为空";
}