#include <stdio.h> #include <stdlib.h> typedef struct Stack { int a[111111]; int top; }Stack,*Node; void push(Node L,int a) { L->a[L->top]=a; L->top++; } void pop(Node L) { if (L->top) { printf("%d\n",L->a[L->top-1]); L->top--; } else { printf("error\n"); } } void top(Node L) { if (L->top) { printf("%d\n",L->a[L->top-1]); } else { printf("error\n"); } } int main() { Stack new; new.top=0; int n; scanf("%d",&n); char s[8]; int temp; for (int i=0; i<n; i++) { scanf("%s",s); if (s[0]=='t') { top(&new); } else if (s[1]=='o') { pop(&new); } else { scanf("%d",&temp); push(&new, temp); } } return 0; }