求问关于链式存储的进栈操作该怎么写 ?只写主函数就行

void L_push(NODE *)malloc(sizeof(LNODE)); p->data=x; p->link=top; top=p; }

天涯尽头无女友
浏览 105回答 1
1回答

芜湖不芜

#include<stdio.h>#include<stdil.h>struct st//链栈的结构体{int data;struct st * next;}node,*link;int kong(link top)//判空栈{if(top==NULL)return 1;else&nbsp;return 0;}link push(link top,int x)//入栈算法{node * p;p=(node *)malloc(sizeof(node));p->data=x;p->next=top;top=p;return(p);}int main()//主函数{int xnode *p;kong(top);printf("请输入要入栈的数\n");scanf("%d",&x);push(top,x);return(0);}只是入栈一个数,如果要做大程序,还得改很多,不过都是在这个基础上的,多点调试,多点想,就不难了,希望对您有帮助。
打开App,查看更多内容
随时随地看视频慕课网APP