#include<stdio.h>
#include<malloc.h>
typedef struct List_Node{
    int info;
    struct List_Node *next;
  }node;//结点结构体
/******************************/
/* 尾插法建立带头结点的单链表 */
/******************************/
node* Creat_Node()
{
    node *head,*pre,*p;
    int x;
    head=(node*)malloc(sizeof(node));;
    head->next=NULL;
    pre=head;
    printf("输入各结点的值,以0结束:");
    while(EOF!=(scanf("%d",&x))&&x!=0)
    {
        p=(node*)malloc(sizeof(node));
        p->info=x;
        p->next=pre->next;
        pre->next=p;
        pre=pre->next;
    }
    return head;
}
/******************************/
/* 头插法建立带头结点的单链表 */
/******************************/
node* Build_Node()
{
    node *head,*p;
    int x;
    head=(node*)malloc(sizeof(node));;
    head->next=NULL;
    printf("输入各结点的值,以0结束:");
    while(EOF!=(scanf("%d",&x))&&x!=0)
    {
        p=(node*)malloc(sizeof(node));
        p->info=x;
        p->next=head->next;
        head->next=p;
    }
    return head;
}
/******************************/
/*         打印单链表         */
/******************************/
void Print_Node(node *head)
{
    node *p=head->next;
    printf("输出该链表:");
    while(p)
    {
        printf("%-5d--->",p->info);
        p=p->next;
    }
    if(p==NULL)
    {
        printf("^\n\n\n");
    }
}

 
											






 
	    