#include <stdio.h>//包含标准输入输出函数
#include <stdlib.h>
//2019-10-24 链表写结果 重要
//依次输入1 2 3 4 0
//结果 3 4 1 2
#define LEN sizeof(struct line)
struct line{
int num;
struct line *next;
};
void main()
{
struct line *p1,*p2,*head;
int j,k=0;
p1=p2=head=(struct line *)malloc(LEN);
scanf("%d",&p1->num);
while(p1->num!=0){
p1 = (struct line *)malloc(LEN);
scanf("%d",&p1->num);
if(p1->num==0)
p2->next=NULL;
else{
p2->next=p1;
p2=p1;
}
k++;
}
p2->next=head;
p1=head->next;
p1=p1->next;
printf("%d\n",k);
for(j=1;j<=k;j++){
printf("-->%d",p1->num);
p1=p1->next;
}
printf("\n");
}