标签:code while scan cin win std == 队列 模拟
#include <bits/stdc++.h>
using namespace std;
const int N=1e6+10;
int q[N],hh,tt;
void init(){
hh=0;
tt=-1;
}
void add(int x){
q[++tt]=x;
}
void remove(){
hh++;
}
int main(){
int m;
cin>>m;
init();
while(m--){
string op;
cin>>op;
int x;
if(op=="push"){
scanf("%d",&x);
add(x);
}else if(op=="pop"){
remove();
}else if(op=="empty"){
if(hh>tt) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}else if(op=="query"){
cout<<q[hh]<<endl;
}
}
return 0;
}
标签:code while scan cin win std == 队列 模拟
原文地址:https://www.cnblogs.com/wiseXu/p/13396684.html