#include <stdio.h>
#include <stdlib.h>
#define N 5
typedef struct list
{
int data;
struct list *next;
}LNode;
LNode *creatlist()
{
LNode *h,*p;
int i,x,n;
h=(LNode *)malloc(sizeof(LNode));
h->next=NULL;
printf("请输入链表结点个个数\n");
scanf("%d",&x);
printf("请依次输入结点的值\n");
while(x--)
{
scanf("%d",&n);
p=(LNode *)malloc(sizeof(LNode));
p->data=n;
p->next=h->next;
h->next=p;
}
return h;
}
void outlist(LNode *h)
{
LNode *p;
p=h->next;
if (p==NULL)
printf("\nThe list is NULL!\n");
else
{
printf("\nHead");
do {
printf("->%d",p->data);
p=p->next;
} while(p!=NULL);
printf("->End\n");
}
}
main( )
{
LNode *A;
A=creatlist();
outlist(A);
}