#include #include "stack.h" using namespace std; int main() { int n; cout << "n = "; cin >> n; stack *s = NULL; char* buf = new char[32]; for (int i = 0; i < n; i++) { cin >> buf; if ('0' <= buf[0] && buf[0] <= '9') { int i = atoi(buf); push(s, i); } else { switch (buf[0]) { case '+': { int o1 = pop(s); int o2 = pop(s); push(s, o2 + o1); } break; case '-': { int o1 = pop(s); int o2 = pop(s); push(s, o2 - o1); } break; case '*': { int o1 = pop(s); int o2 = pop(s); push(s, o2 * o1); } break; } } } int result = pop(s); cout << "Result = " << result << endl; return 0; }