/*******************************/
/*tn10000@126.com/ */
/*******************************/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
struct node
{
int num;
struct node* next;
};
struct node * create(struct node *head);
void print(struct node *head);
int main(){
struct node *head;
head = NULL;
head = create(head);
print(head);
return 0;
}
struct node *create(struct node *head){
int i=0;
struct node *p1, *p2;
p1 = p2 = (struct node*)malloc(sizeof(struct node));
memset(p1, 0, sizeof(struct node));
scanf("%d", &p1->num);
p1->next=NULL;
while(p1->next>0){
if (head==NULL){
head=p1;
}else{
p2->next=p1;
}
p2=p1;
p1=(struct node*)malloc(sizeof(struct node));
memset(p1, 0, sizeof(struct node));
scanf("%d", &p1->num);
p1->next=NULL;
i++;
}
printf("\n total:%d\n", i);
return head;
}
void print(struct node *head){
struct node *temp;
temp = head;
while(temp != NULL){
printf("%6d\n", temp->num);
temp=temp->next;
}
}