高手进!急~~等待答案中!!

来源:百度知道 编辑:UC知道 时间:2024/05/28 23:54:32
下面的程序哪里错了!!
望哪位高人指出!!我用的是win-tc编译器
#include<stdio.h>
#include<conio.h>
struct list
{
int data;
struct list * next;
};
typedef struct list node;
node * creat();
node * deletelist(node *);

int main()
{
node * head,* tail;
head = creat();
head = deletelist(head);
for(tail = head->next;tail!=NULL;tail = tail->next)
printf(" %d ", tail->data);
getch();
return 0;
}

node * creat()
{
node * head,* p,* tail;
int a;
head = (node *)malloc(sizeof (node));
head->next = NULL;
tail = head;
scanf("%d", &a);
while(a!=0)
{
p = (node *)malloc(sizeof (node));
p->next = NULL;
p->data = a;
tail->next = p;
tail = tai

少一个头函数文件#include<stdlib.h>,这里有错误node * deletelist(head) ,我已经给你改了,你看看好了没有?
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
struct list
{
int data;
struct list * next;
};
typedef struct list node;
node * creat();
node * deletelist(node *);

int main()
{
node * head,* tail;
head = creat();
head = deletelist(head);
for(tail = head->next;tail!=NULL;tail = tail->next)
printf(" %d ", tail->data);
getch();
return 0;
}

node * creat()
{
node * head,* p,* tail;
int a;
head = (node *)malloc(sizeof (node));
head->next = NULL;
tail = head;
scanf("%d", &a);
while(a!=0)
{
p = (node *)malloc(sizeof (node));
p->next = NULL;
p->data = a;
tail->next = p;
tail = tail->next;
scanf("%d", &a);