#include "stdio.h"
#include "stdlib.h"
struct list_head{
struct list_head *prev;
struct list_head *next;
};
struct task{
int member;
struct list_head list;
};
#define list_entry(ptr,member,type) \
((type*)((char *)ptr-(unsigned long)&(((type*))->member)))
#define Init_list(list) {&list,&list}
static void list_add(struct list_head* ptr,struct list_head* n){
ptr->next=n->next;
n->next->prev=ptr;
n->next=ptr;
ptr->prev=n;
}
#define for_each(list_)\
for(pos=list_.next;pos!=&list_;pos=pos->next)\
{printf("%d ",list_entry(pos,list,struct task)->member);}\
printf("\n");
void main(){
struct task* tmp;
int i;
struct list_head mylist=Init_list(mylist),*pos;
for( i=;i<;i++){
tmp=(struct task*)malloc(sizeof(struct task));
scanf("%d",&(tmp->member));
list_add(&(tmp->list),&mylist);
}
for_each(mylist);
}