|
发表于 2020-4-7 00:00:01
|
显示全部楼层
struct node
{
char *name;
struct node *next;
};
struct node *Head;
Head->name=NULL;
Head->next=NULL;
void insert(struct node *newnode)
{
struct node *p,*q;
p=Head;
q=p;
if(p->next==NULL)
{
p->next=newnode;
newnode->next=NULL;
}
else
{
while(p->next!=NULL || strcmp(p->name,newnode->name)<0 )
{
q=p;
p=p->next;
}
q->next=newnod;
newnod->next=q;
}
return;
}
void del(struct node *oldnode)
{
struct node *p,*q;
p=Head;
if(p->next==NULL)
{
printf("there is no data\n");
exit(1);
}
else
{
while(p->next!=NULL || strcmp(p->name,oldnode->name)!=0)
{
q=p;
p=p->next;
}
q->next=p->next;
delete(p);
}
return;
}
刚写的 兄弟帮忙找找错误
还有 那个顺序查找要不要采用好的算法? |
|