链表有一系列节点组成,一个节点有两个域:数据域,指针域(保存下一个节点地址),
链表在内存中是非连续的。
可以依据指针随机插入、删除元素。
静态链表
struct LinkNode{int data;struct LinkNode *next;};void test(){struct LinkNode node1 = {1, NULL};struct LinkNode node2 = { 2, NULL};struct LinkNode node3 = { 3, null};struct LinkNode node4 = { 4, null};node1.next = &node2;node2.next = &node3;node3.next = &node4;// 遍历链表struct LinkNode *Pcurrent = &node1;while(Pcurrent != NULL){printf("%d ", Pcurrent->data);Pcurrent = Pcurrent->next;}}int main(){test();return 0;}
