#include
#include
typedef struct Node
{
int data;
struct Node *next;
}Node;
void append(Node *head)
{
int n;
Node *p,*news=NULL;
p=head;//保存首地址
while(1)
{
scanf("%d",&n);
if(n==-1)
{
break;
}
p->data=n;
news=(Node *)malloc(sizeof(Node));
news->next=NULL;
p->next=news;
p=news;
}
p=NULL;
}
void print(Node *head)
{
Node *p;
p=head;
while(p!=NULL)
{
printf("%d\t",p->data);
p=p->next;
}
}
int main()
{
Node *head=NULL;
head=(Node *)malloc(sizeof(Node));
append(head);
print(head);
return 0;
}