标签:des style http color io os ar java for
2 6 Add 18353364208 Add 18353365550 Add 18353365558 Add 18353365559 Del Out
18353365558 18353364208
#include <stdio.h> #include <string.h> #include <stdlib.h> #include <algorithm> #include <iostream> #include <queue> #include <stack> #include <string> using namespace std; int main() { char str[20]; string s; int flag=0;//用来标记栈和队列是否为空。如为空还继续进行Del或者Out操作,则输出Error; int n,m,i; while(~scanf("%d %d",&n,&m)) { stack<string >p;//记得要在循环里面建栈和队列,wa3次,哭瞎了。 queue<string >q; flag=0; for(i=1; i<=m; i++) { cin>>str; if(strcmp(str,"Add")==0) { cin>>s; if(p.size()==n)//此时证明停车场满了 q.push(s);//则车辆进入便道 else p.push(s); } else if(strcmp(str,"Del")==0) { if(p.empty()) flag=1; else { p.pop(); if(!q.empty()) { p.push(q.front()); q.pop(); } } } else if(strcmp(str,"Out")==0) { if(q.empty()) flag=1; else q.pop(); } } if(flag) cout<<"Error"<<endl; else { while(!p.empty()) { cout<<p.top()<<endl; p.pop(); } } } return 0; }
标签:des style http color io os ar java for
原文地址:http://blog.csdn.net/u013486414/article/details/39728117