qq_32481541 2016-03-27 12:21 采纳率: 100%
浏览 1362
已采纳

我想问一下这个应该怎么改?

#include
#include

struct node
{
int data;
struct node *next;
};
typedef struct node NODE;
NODE *ApplyNODE(int x)
{
NODE *p;
p=(NODE *) malloc (sizeof(NODE));
p->data=x;
p->next=NULL;
return(p);
}
NODE *InitList()
{
NODE *head;
head=(NODE *) malloc (sizeof(NODE));
head->next=NULL;
return(head);
}
NODE *creat(int n)//创建链表

{

NODE *head,*p,*q;

int i,m,x;
printf("\nInput the length of the line:");
scanf("%d",&m);
head=q=InitList();
printf("\nInput %d datas:",m);
head=p=q=(NODE *)malloc(sizeof(NODE));//创建节点

for(i=0;i {
if(q->next!=NULL)

{

scanf("%d",&x);
p=ApplyNODE(x);
q->next=p;//q->next保存p,q指向最后一个节点

q=p;

p=(NODE *)malloc(sizeof(NODE));//创建下一个节点

}

}

q->next=NULL;

return head;

}

NODE *search(NODE *head,int x)//查找数据

{
NODE *p=head;

p=head->next;
while((p!=NULL)&&(p->data!=x))
p=p->next;
return(p);

}
NODE *delete(NODE *head, int x)//删除节点

{
NODE *q;
q=head;
while(q->next->data!=x)
q=q->next;
q->next=q->next->next;

return(head);

}
void Display(NODE *head)
{
NODE *p;
printf("\nThe line are:");
p=head->next;
while(p!=head)
{
printf("%d",p->data);
p=p->next;
}
}
main()
{
int n,x;
NODE *head;
head=creat(n);
head=delete(head,x);
Display(head);
search(head,x);

}

  • 写回答

4条回答 默认 最新

  • threenewbee 2016-03-27 12:51
    关注

    delete是关键字不能作为函数名

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?