typedef struct node *link; struct noed{ int item; link next; }; static link head = NULL; link make_node(int item) { link p = malloc(sizeof *p); p->item = item; p->next = next; return p; } void indert(link p) { p->next = head; head = p; } link delete(link p) { link prev; if(p == head){ head = p->next; return p; } for (prev = head; prev; prev = prev->next) if(prev->next == p){ prev->next = p->next; return p; } return NULL; } /*第二种单链表删除操作,更为简洁*/ link delete(link p) { link *pnext; for (pnext = &head; *pnext; pnext = &(*penxt)->next) if(*pnext == p){ *pnext = p->next; return p; } return NULL; } void print(link p) { for (p = head; p; p = p->next) printf("%d/n", p->item); } void free_node(link p) { free(p); } void destory(void) { link q, p = head; head = NULL; while (p){ q = p; p = p->next; free(q); } } void push(link p) { insert(p); } link pop(void) { if (head == NULL) return NULL; else return delete(head); }