#include <iostream>
#include <cstring>
using namespace std;
const int maxn = 100000 + 5;
int q[maxn];
int m, x, hh, tt = -1;
string s;
int main()
{
cin >> m;
while (m --)
{
cin >> s;
if (s == "push")
{
cin >> x;
q[++ tt] = x;
}
if (s == "query")
{
cout << q[hh] << endl;
}
if (s == "pop")
{
hh ++;
}
if (s == "empty")
{
cout << (hh <= tt ? "NO" : "YES") << endl;
}
}
return 0;
}
C++队列
最新推荐文章于 2023-07-09 21:35:14 发布