stack操作
堆栈的使用
http://www.nowcoder.com/questionTerminal/e91982a145944ceab6bb9a4a508e0e26
#include<iostream>
#include<stack>
using namespace std;
int main()
{
int n,c=0,x;
char op;
while(scanf("%d ",&n)!=EOF&&n!=0)
{
stack<int> a;
if(c>0) printf("\n");
while(n--)
{
scanf("%c ",&op);
if(op=='P')
{
scanf("%d ",&x);
a.push(x);
}
else if(op=='O')
{
if(!a.empty()) a.pop();
}
else if(op=='A')
{
if(!a.empty()) printf("%d\n",a.top());
else printf("E\n");
}
}
c++;
}
return 0;
} (•̀ᴗ•́)و
360集团公司氛围 400人发布