#include <stdio.h>
#include <stdlib.h>
struct link{
int data;
struct link *next;
};
struct list{
struct link *head;
struct link *tail;
};
struct link * add_tail(struct list *lst, int value){
struct link
*item
= (struct link
*)malloc(sizeof(struct link
)); item->data = value;
item->next = NULL;
if(lst->head == NULL){
lst->head = item;
lst->tail = lst->head;
}else{
lst->tail->next = item;
lst->tail = item;
}
return item;
}
void print(struct list *lst){
struct link *p = lst->head;
while(p){
p = p->next;
}
}
int main(){
struct list lst;
lst.head = lst.tail = NULL;
int in;
while(scanf("%d", &in
) == 1){ add_tail(&lst, in);
}
print(&lst);
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnN0cnVjdCBsaW5rewoJaW50IGRhdGE7CglzdHJ1Y3QgbGluayAqbmV4dDsKfTsKCnN0cnVjdCBsaXN0ewoJc3RydWN0IGxpbmsgKmhlYWQ7CglzdHJ1Y3QgbGluayAqdGFpbDsKfTsKCnN0cnVjdCBsaW5rICogYWRkX3RhaWwoc3RydWN0IGxpc3QgKmxzdCwgaW50IHZhbHVlKXsKCXN0cnVjdCBsaW5rICppdGVtID0gKHN0cnVjdCBsaW5rICopbWFsbG9jKHNpemVvZihzdHJ1Y3QgbGluaykpOwoJaXRlbS0+ZGF0YSA9IHZhbHVlOwoJaXRlbS0+bmV4dCA9IE5VTEw7CglpZihsc3QtPmhlYWQgPT0gTlVMTCl7CgkJbHN0LT5oZWFkID0gaXRlbTsKCQlsc3QtPnRhaWwgPSBsc3QtPmhlYWQ7Cgl9ZWxzZXsKCQlsc3QtPnRhaWwtPm5leHQgPSBpdGVtOwoJCWxzdC0+dGFpbCA9IGl0ZW07Cgl9CglyZXR1cm4gaXRlbTsKfQoKdm9pZCBwcmludChzdHJ1Y3QgbGlzdCAqbHN0KXsKCXN0cnVjdCBsaW5rICpwID0gbHN0LT5oZWFkOwoJd2hpbGUocCl7CgkJcHJpbnRmKCIlZFxuIiwgcC0+ZGF0YSk7CgkJcCA9IHAtPm5leHQ7Cgl9Cn0KCmludCBtYWluKCl7CglzdHJ1Y3QgbGlzdCBsc3Q7Cglsc3QuaGVhZCA9IGxzdC50YWlsID0gTlVMTDsKCWludCBpbjsKCgl3aGlsZShzY2FuZigiJWQiLCAmaW4pID09IDEpewoJCWFkZF90YWlsKCZsc3QsIGluKTsKCX0KCXByaW50KCZsc3QpOwp9