HDU 1702 ACboy needs your help again!(栈和队列的简单应用)

题目链接:HDU 1702 ACboy needs your help again!
HDU 1702	ACboy needs your help again!(栈和队列的简单应用)
HDU 1702	ACboy needs your help again!(栈和队列的简单应用)

啥错都范,return 0; 忘写了。。。

#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
using namespace std;

int main()
{
	int t,n,m;
	cin>>t;
	string s,com;
	queue<int> q;
	stack<int> st;
	while(t--)
	{
		while(!q.empty()) q.pop();
		while(!st.empty()) st.pop();
		
		cin>>n>>s;
		while(n--)
		{
			cin>>com;
			if(s=="FIFO")
			{
				if(com=="IN")
				{
					cin>>m;
					q.push(m);
				}
				else if(com=="OUT")
				{
					if(!q.empty())
					{
						printf("%d\n",q.front());
						q.pop();
					} 	
					else
						printf("None\n");
				}
			}
			else if(s=="FILO")
			{
				if(com=="IN")
				{
					cin>>m;
					st.push(m);
				}
				else if(com=="OUT")
				{
					if(!st.empty())
					{
						printf("%d\n",st.top());
						st.pop();
					}	
					else
						printf("None\n");
				}
			}	
		}
	}
	
	return 0;
}
上一篇:# Doing homework again(贪心)


下一篇:$Android设置TextView的字体