- 主要用vector来实现队列。
#include<bits/stdc++.h>
using namespace std;
int main()
{
int T,Q;
cin>>T;
string temp1;
int temp2;
vector<int> temp3;
for(int i=0;i<T;++i)
{
temp3.clear();//一些操作时没有clear得注意这个陷阱。
cin>>Q;
for(int j=0;j<Q;++j)
{
cin>>temp1;
if(temp1=="PUSH")
{
cin>>temp2;
temp3.push_back(temp2);
}
else if(temp1=="TOP")
{
if(temp3.size()>0) cout<<temp3[0]<<endl;
else cout<<-1<<endl;
}
else if(temp1=="POP")
{
if(temp3.size()>0) temp3.erase(temp3.begin());
else cout<<-1<<endl;
}
else if(temp1=="SIZE") cout<<temp3.size()<<endl;
else temp3.clear();
}
}
return 0;
}