//
// #include<bits/stdc++.h>
#include<iostream>
#include<stack>
#include<queue>
#include<string>
using namespace std;
int main()
{
string s,op;
int t,n,x;
cin>>t;
while( t-- )
{
cin>>n>>s;
if( s=="FIFO" )
{
queue<int> q;
while( n-- )
{
cin>>op;
if( op=="IN" ) { cin>>x; q.push( x ); }
else if( op=="OUT" )
{
if( q.empty() ) cout<<"None"<<endl;
else { cout<<q.front()<<endl; q.pop(); }
}
}
}
else if( s=="FILO" )
{
stack<int> sk;
while( n-- )
{
cin>>op;
if( op=="IN" ) { cin>>x; sk.push( x ); }
else if( op=="OUT" )
{
if( sk.empty() ) cout<<"None"<<endl;
else { cout<<sk.top()<<endl; sk.pop(); }
}
}
} // FILO
} // t
return 0;
}
VJ_ACboy needs your help again_stack_queue
猜你喜欢
转载自blog.csdn.net/qq_63173957/article/details/124614407
今日推荐
周排行