栈的基本操C语言实现.docVIP

  • 2
  • 0
  • 约2.8万字
  • 约 6页
  • 2016-12-25 发布于河南
  • 举报
#includestdio.h #includestdlib.h #define length sizeof(struct node) struct node { int data; struct node *next; };//定义结点 void Crestack(struct node **p)//创建栈 { struct node *q; q=(struct node*)malloc(length); q=NULL; *p=q; } void push(struct node **p,int x) //压栈 { struct node *q; q=(struct node *)malloc(sizeof(struct node)); q-data=x; q-next=*p; *p=q; } int pop(struct node **p) //出栈 { struct node *q; q=*p; if(*p==NULL) printf(提示:栈空 !\n); else { *p=(*p)-next; } return(q-data); } void display(struct node **p)

文档评论(0)

1亿VIP精品文档

相关文档