#include <stdlib.h>
typedef struct STACKnode* link;
struct STACKnode { int item; link next; };
static link head;
link NEW(int item, link next)      
  { link x = malloc(sizeof *x);
    x->item = item; x->next = next;     
    return x;                         
  }                                   
void STACKinit(int maxN) 
  { head = NULL; }
int STACKempty()
  { return head == NULL; }
STACKpush(int item)
  { head = NEW(item, head); }
int STACKpop()
  { int item = head->item;
    link t = head->next; 
    free(head); head = t;
    return item;
  }
