#include <stdio.h>
//数组:地址是连续的 不易增删 不灵活
//链表:不连续 灵活
struct Test
{
int data;
struct Test *next;
};
void printlink(struct Test *head)//链表动态遍历
{
struct Test *point;
point = head;
while (point != NULL){
printf("%d ",point ->data);
point = point ->next;
}
putchar('\n');
}
int main()
{
//链表的静态添加
struct Test t1 = {1,NULL};
struct Test t2 = {2,NULL};
struct Test t3 = {3,NULL};
struct Test t4 = {4,NULL};
struct Test t5 = {5,NULL};
struct Test t6 = {6,NULL};
t1.next = &t2;
t2.next = &t3;
t3.next = &t4;
t4.next = &t5;
t5.next = &t6;
printlink(&t1);
return 0;
}```
demo9.3链表的静态添加和动态遍历.c
最新推荐文章于 2025-12-06 21:23:07 发布
1677

被折叠的 条评论
为什么被折叠?



