数据结构链栈
发布日期:2021-06-30 11:48:00 浏览次数:2 分类:技术文章

本文共 478 字,大约阅读时间需要 1 分钟。

//链栈#include
#include
struct node{ int data; struct node *next;};main(){ struct node *top,*p,*q; int x; scanf("%d",&x); top=(struct node *)malloc(sizeof(struct node)); //产生一个节点 top->next=NULL; printf("\n%d=",x);while(x!=0) //入栈{ p=(struct node *)malloc(sizeof(struct node)); //产生节点 p->data=x%2; p->next=top->next; //现在的节点指向top后的元素 top->next=p; x=x/2;}while(top->next!=NULL){ q=top->next; printf("%d",q->data); top->next=q->next; free(q);}printf("\n");}

 

转载地址:https://jackiehao.blog.csdn.net/article/details/101673054 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:链式栈进制转换
下一篇:数据结构顺序栈

发表评论

最新留言

网站不错 人气很旺了 加油
[***.192.178.218]2024年04月27日 12时53分20秒