http://ac.jobdu.com/problem.php?pid=1108
题目比较简单
#include<stdio.h>
#include<string.h>
#include<fstream>
#include<iostream>
using namespace std;
int main(){
int n;
ifstream cin("data.txt");
while (cin >> n && n !=0 )
{
int i, tail = -1;
char operation;
int *stack = new int[n];
for (i = 0; i < n; i++)
{
cin >> operation;
if (operation == 'P')
cin >> stack[++tail];
else if (operation == 'O')
{
if (tail == -1)
tail = -1;
else
tail--;
}
else if (operation == 'A') //查询
{
if (tail >= 0)
cout << stack[tail] << endl;
else
cout << "E" << endl;
}
}
cout << endl;
}
system("pause");
return 0;
}