# Include <stdio. h>
# Include <stdlib. h>
Typedef struct Link
{
Struct link * before;
Int data;
Struct link * next;
} Node, * pnode;
Typedef struct real_link
{
Int size;
Struct link head;
Pnode tail;
} List, * plist;
Void initialize (plist mylist)
{
Mylist-> head. Before = NULL;
Mylist-> head. Next = NULL;
Mylist-> head. Data = 0;
Mylist-> tail = NULL;
Mylist-> size = 0;
}
Void creat (plist mylist1)
{
Int I;
Pnode TMP = & mylist1-> head;
While (scanf ("% d", & I ))
{
Pnode p1 = (pnode) malloc (sizeof (node ));
P1-> DATA = I;
Mylist1-> size ++;
P1-> next = NULL;
TMP-> next = p1;
P1-> before = TMP;
TMP = TMP-> next;
Mylist1-> tail = p1;
P1-> next = mylist1-> head. Next; // The End Of The linked list is connected to the header.
Mylist1-> head. Next-> before = p1; // implement Loop
}
Printf ("created successfully \ n ");
}
Void kill (plist mylist, int I)
{
Pnode TMP = NULL;
While (mylist-> size! = 1)
{
Int COUNT = 0;
If (mylist-> size = 6)
{
TMP = mylist-> head. Next;
}
While (count <I)
{
TMP = TMP-> next;
Count ++;
}
Sleep (1 );
Printf ("% d suicide success \ n", TMP-> data );
Pnode ptr1 = TMP-> before;
Pnode ptr2 = TMP-> next;
Free (TMP );
Ptr1-> next = ptr2;
Ptr2-> before = ptr1;
Mylist-> size --;
TMP = ptr2;
}
}
Int main (void ){
List DM;
Initialize (& DM );
Creat (& DM );
Kill (& DM, 23 );
Return exit_success;
}