谁能帮我调试下,下面的代码

来源:百度知道 编辑:UC知道 时间:2024/05/31 09:43:45
#include<stdio.h>
#include<stdlib.h>
struct node *create(int n);
void print_link(struct node *head);
struct node*delet(struct node *head,int date);
typedef struct node
{int date;struct node *next;};
void main()
{ int i,del_date;
struct node *head;
printf("输入:\n");
scanf("%d",&i);
struct node *dat,*p;
head=create(i);
print_link(head);
head=delet(head,del_date);
print_link(head);
p=head;
}
struct node *create(int n)
{ int i;
struct node *head=NULL,*p1,*p2;
head=p2=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p2->date);
for(i=0;i<n;i++)
{ p1=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p1->date);
p2->next=p1;
p2=p1;}
p2->next=NULL;
return(head);
}
void print_link(struct node *head)
{ struct no

#include<stdio.h>
#include<stdlib.h>
struct node *create(int n);
void print_link(struct node *head);
struct node*delet(struct node *head,int date);
struct node
{
int date;struct node *next;
};
void main()
{
int i,del_date;
struct node *head;
printf("输入你要输入的元素的个数:\n");
scanf("%d",&i); /////////////////////// 这里是元素个数
struct node *p;
head=create(i); // 建立链表
printf("这个链表为\n");
print_link(head); // 打印链表
printf("你要删除第几个元素\n");
scanf("%d",&del_date); // 删除第 del_date个元素
head=delet(head,del_date);
printf("这个链表为\n");
print_link(head); // 打印删除后的链表
p=head;
}
struct node *create(int n) // 建立链表
{
int i;
struct node *head=NULL,*p1,*p2;
head=p2=(struct node*)malloc(sizeof(struct node));
scanf("%d",&p2->date);