什么是链表:数据结构,数据存放的思想,每一项都是结构体,都有存放数据和下一项的指针,地址不必连续,很灵活
链表头:head
struct Test{int data;struct Test *next;};
链表操作分为:遍历,插入(头插,尾插),删除,查找。
链表的动态创建:先:struct Test *haed=NULL;
在进行头插:new=(struct Test*)malloc(sizeof(struct Test));
scanf("%d",&(new->data));
if(head==NULL)
{head = new;return haed;}
new->next=head;
return head;
或尾插法:new=(struct Test*)malloc(sizeof(struct Test));
struct Test *p=head;
scanf("%d",&(new->data));
if(p==NULL)
{p = new;return haed;}
while(p->next != NULL)
{p=p->next;}
p->next=new;
return head;