迅速使静态链表 [英] Quickly make a static linked list
本文介绍了迅速使静态链表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要赶紧做一个静态的链表,用尽可能少code越好,这是非常可读,无杂乱。我如何做到这一点优雅?
像
1 - > 2 - > 3 - > 4 - > NULL
解决方案
结构节点{INT X;结构节点*旁边;};
缺点#定义(X,旁边)(结构节点[]){{X,接下来}}
结构节点*头=缺点(1,缺点(2,缺点(3,缺点(4,NULL))));
I want to quickly make a static linked list, with as little code as possible, which is very readable and without clutter. How do i accomplish this elegantly?
something like
1 -> 2 -> 3 -> 4 -> NULL
解决方案
struct node {int x; struct node *next;};
#define cons(x,next) (struct node[]){{x,next}}
struct node *head = cons(1, cons(2, cons(3, cons(4, NULL))));
这篇关于迅速使静态链表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文