struct test
{
int data;
struct test *next;
};
void printLink(struct test *head)
{
struct test *p = head;
while(p != NULL)
{
printf("%d ",p->data);
p=p->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 *head = &t1;
t1.next = &t2;
t2.next = &t3;
t3.next = &t4;
t4.next = &t5;
printLink(head);
return 0;
}
链表(静态添加、动态遍历)
最新推荐文章于 2024-08-25 03:49:49 发布