#include <stdio.h>
#include <malloc.h>
#include <string.h>
typedef struct node
{
char num[20];
char name[20];
char sex[5];
char major[20];
char phone[20];
node *next;
}*List;
List insert(List head,node x)
{
if(head == NULL)
{
head=(List)malloc(sizeof(node));
strcpy(head->num,x.num);
strcpy(head->name,x.name);
strcpy(head->sex,x.sex);
strcpy(head->major,x.major);
strcpy(head->phone,x.phone);
head->next=NULL;
}
else
{
List p=head;
while(p->next!=NULL)
{
p=p->next;
}
p->next=(List)malloc(sizeof(node));
strcpy(p->next->num,x.num);
strcpy(p->next->name,x.name);
strcpy(p->next->sex,x.sex);
strcpy(p->next->major,x.major);
strcpy(p->next->phone,x.phone);
p->next->next=NULL;
}
return head; //
}
List serac(List head,char num[])
{
List p=head;
int flag=0;
w
链表基本操作
最新推荐文章于 2023-06-25 15:21:54 发布
本文深入探讨了链表的基础知识,包括链表的定义、插入、删除、遍历等核心操作,帮助读者理解链表的数据结构及其在编程中的应用。
摘要由CSDN通过智能技术生成