📄 querybyxuehao.c
字号:
#include "stdio.h"
#define NULL 0
struct node
{
int data;
struct node *next;
};
struct node *creat();
struct node *delete(struct node *head,int value)
{ struct node *p,*q;
p=head;
if(head==NULL)
{ printf("这是一个空连接表!\n");
return (head);
}
while((p->next!=NULL)&&(p->data!=value))
{ q=p;p=p->next;}
if(value==p->data)
{ if(head==p) head=p->next;
else q->next=p->next;
free(p);
}
else
printf("此链表没有数据%d!\n",value);
return(head);
}
void main()
{
struct node *q;
int value;
q=creat();
printf("请输入要删除的数据:");
scanf("%d",&value);
q=delete(q,value);
printf("The data of link:\n");
while(q!=NULL)
{
printf("%d\t",q->data);
q=q->next;
}
printf("\n");
getch();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -