链表节点的删除
#include <stdio.h>#include <stdlib.h>
#define Max 10
struct list
{
int number;
int total;
struct list *next;
};
typedef struct list node;
typedef node *link;//节点的声明
//输入数据
int data[2][Max] =
{
1,3,5,7,2,4,6,8,9,10,15,35,10,67,25,65,38,70,30,20
};
//删除链表内的节点
link Delete_list(link head,int key)
{
link pointer;
link back;
pointer = head;//pointer设为首节点
while(1)
{
if( pointer->next == NULL)
{
printf("Not Found!!\n");
break;
}
if( head->number == key)//删除节点
{
head = pointer->next;//指向
free(pointer);
break;
}
back = pointer;//??
pointer = pointer->next;
if( pointer->number == key)//插入链表的中部或尾端
{
back->next = pointer->next;//改接
free(pointer);
break;
}
}
return head;
}
//释放链表的节点
void Free_list(link head)
{
link pointer;
while( pointer != NULL)
{
pointer = head;
head = head->next;//移向下一结点
free(pointer);
}
}
//输出链表
void Print_list(link head)
{
link pointer;
pointer = head;//pointer设为首节点
while( pointer != NULL)//节点为空时结束循环
{
printf("[%d,%d]",pointer->number,pointer->total);
pointer = pointer->next;
}
printf("\n");
}
//建立链表
link Create_list(link head)
{
link pointer;
link new;
int i;
head = (link)malloc(sizeof(node));
if( head == NULL)
{
printf("Memory allocate failure!!\n");
}
else
{
head->number = data[0][0];
head->total = data[1][0];
head->next = NULL;
pointer = head;
for(i = 0;i <= Max;i++)
{
new = (link)malloc(sizeof(node));
new->number = data[0][i];
new->total = data[1][i];
new->next = NULL;
pointer->next = new;//连接
pointer = new;//列表尾端为新节点
}
}
return head;
}
//主程序
int main()
{
link head;
int key;
head = Create_list(head);//调用创立链表
if( head != NULL)
{
Print_list(head);
while(1)
{
printf("Input 0 to EXIT!\n");
printf("Please input the data to delete : ");
scanf("%d",&key);
if( key == 0)
break;
head = Delete_list(head);//调用插入节点
Print_list(head);//调出链表数据
}
Free_list(head);
}
}
\Untitled1.c|137|error: too few arguments to function 'Delete_list'|
这个错误 怎么回事 帮忙整下吧