#include <stdio.h>
#include <stdlib.h>
//the first linklist
typedef int datatype ;
typedef struct list
{
datatype data ;
struct list *next ;
}linklist,*link;
void init_list(link *head )
{
*head =(link)malloc(sizeof(linklist));
(*head)->next =NULL;
}
void insert_list(link head, int x)
{
/*first malloc a node of list and set data and next pointer of node */
link new = (link)malloc(sizeof(linklist));
new->data =x; // data
new->next =NULL; //next point
link q =head ; //
while(q->next !=NULL)
q=q->next ; //这两句是q的指针移动到最后
q->next =new ; //然后把q的next 指向 new这个node
}
void show(link head)
{
link q = head->next;
while(q !=NULL)
{
printf("%d\t ",q->data );
q=q->next ;
}
printf("\n");
}
int main(void)
{
link head;
init_list(&head);
int tmp,ret;
while(1)
{
ret= scanf("%d\n",&tmp);
if(ret!=1)
break;
insert_list(head,tmp);
show(head);
}
return 0 ;
}