#include <iostream>
#include <stack>
#include <string>
using namespace std;
int main() {
stack<char> s;
string str;
char c;
while (cin >> str) {
if (str == "quit") break;
else if (str == "pop") {
cout << s.top() << endl;
s.pop();
} else {
cin >> c;
s.push(c);
}
}
return 0;
}
|