C++ 代码
#include <iostream>
using namespace std;
const int N = 100010;
int q[N];
int tail,head;
int main(){
int n;
cin >> n;
while(n--){
string op;
cin >> op;
int x;
if(op == "push"){
cin >> x;
q[tail++] = x;
}else if(op == "pop"){
++head;
}
else if(op == "empty"){
cout << ( (head == tail ? "YES" : "NO") ) << endl;
}else{
cout << q[head] << endl;
}
}
return 0;
}