Chinaunix首页 | 论坛 | 博客
  • 博客访问: 587874
  • 博文数量: 126
  • 博客积分: 4379
  • 博客等级: 上校
  • 技术积分: 2110
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-06 22:35
文章分类

全部博文(126)

文章存档

2012年(5)

2011年(3)

2010年(2)

2009年(116)

分类: LINUX

2009-03-28 21:35:38

typedef int ElemType;
/* 节点的类型(包括头节点) */
typedef struct Node{
  ElemType elem;
  struct Node *next;
}SNode;
/* 初始化,头节点 */
InitStack(SNode* pS)
{
  pS->next=NULL;
}
/* 入栈:在头节点之后插入一个新节点 */
Push(SNode* pS,ElemType e)
{
  SNode* node;
  node = (SNode*)malloc(sizeof(SNode));
  node->elem = e;
  node->next = pS->next;
  pS->next = node;
}
int Pop(SNode* pS,ElemType* pe)
{
  SNode* node;
  if (pS->next==NULL){
    return 0;
  }
  *pe = pS->next->elem;
  node=pS->next;
  pS->next=node->next;
  free(node);
  return 1; 
}
阅读(1036) | 评论(0) | 转发(0) |
0

上一篇:队列的链式实现

下一篇:表的链式实现

给主人留下些什么吧!~~