#include"stdio.h"
#include "stdlib.h"
#define NULL 0
#define LEN sizeof(struct node)
typedef int datatype;
typedef struct node
{ datatype data;
struct node *next;
}linklist;
linklist *hrear_creat()
{
int x;
linklist *head,*p,*rear;
head=(struct node*)malloc (LEN);
head->data=-999;
rear=head;
printf("请输入以整数0结束符");
scanf("%d,&x");
while(x!=0)
{
p=(struct node*)malloc(LEN);
p->data=x;
rear->next=p;
rear=p;
scanf("%d",&x);
}
rear->next=NULL;
return(head);
}
int main()
{
linklist *hrear_creat();
return 0;
}
用尾插法建立一个带头结点的单链表的算法
最新推荐文章于 2024-07-13 20:44:28 发布