#include
#include
typedef struct _node
{
int data;
struct _node * next;
}Node;
typedef struct _list{
Node* head;
}List;
Node* add(Node* head,int number)
{
//add to linked-list
Node *p=(Node *)malloc(sizeof(Node));
p->data=number;
p->next=NULL;
//find the last
Node *last =head;
printf("%d",last);
if(last){
while(last->next){
last =last->next;
}
//attach to
last->next=p;
}else{
last=p;
}
return head;
}
void travel_L(Node *head){
Node * p;
if(head=NULL)
printf("xxx");
p=head->next;
while(p!=NULL){
printf("%d",p->data);
p=p->next;
}
}
int main(){
int number;
Node *head=NULL;
// printf("%d",head);
do{
scanf("%d",&number);
if(number!=-1){
head=add(head,number);
}
}while (number!=-1);
travel_L(head);
return 0;
}