# Include <stdio. h>
# Include <stdlib. h>
Typedef struct _ list
{
Int data;
Struct _ list * next;
} List, * plist;
Plist create_list (int * a, int Len)
{
Plist head = NULL;
Plist PTR = NULL;
Plist newnode = NULL;
Head = (plist) malloc (sizeof (list ));
Head-> DATA = A [0];
Head-> next = NULL;
PTR = head;
For (INT I = 1; I <10; I ++)
{
Newnode = (plist) malloc (sizeof (list ));
Newnode-> DATA = A [I];
Newnode-> next = NULL;
PTR-> next = newnode;
PTR = PTR-> next;
}
Return head;
}
Plist insert_node (plist head, int data, int POS)
{
Plist node, PTR;
PTR = head;
Node = (plist) malloc (sizeof (list ));
Node-> DATA = data;
Node-> next = NULL;
If (Pos = 0)
{
Node-> next = head;
Return node;
}
Else
{
For (INT I = 0; I <POS & PTR-> next! = NULL; I ++)
{
PTR = PTR-> next;
}
Node-> next = PTR-> next;
PTR-> next = node;
Return head;
}
}
Void print_list (plist head)
{
Plist PTR = head;
While (PTR! = NULL)
{
Printf ("% d", PTR-> data );
PTR = PTR-> next;
}
Printf ("\ n ");
}
Plist delete_node (plist head, int POS)
{
Plist PTR = head;
Plist temp = NULL;
If (Pos = 0)
{
PTR = head-> next;
Free (head );
Return PTR;
}
Else
{
For (INT I = 1; I <pos-1 & PTR-> next! = NULL; I ++)
{
PTR = PTR-> next;
}
If (PTR-> next! = NULL)
{
Temp = PTR-> next;
PTR-> next = temp-> next;
Free (temp );
Return head;
}
Else
{
Free (PTR-> next );
PTR-> next = NULL;
}
}
}
Plist reverse_list (plist head)
{
Plist A, B, C;
A = NULL;
B = head;
C = head-> next;
While (B-> next! = NULL)
{
B-> next =;
A = B;
B = C;
C = C-> next;
}
B-> next =;
Return B;
}
Int main (void)
{
Int A [10];
For (INT I = 0; I <10; I ++)
{
A [I] = I;
}
Plist head = NULL;
Head = create_list (A, 10 );
Print_list (head );
Head = insert_node (Head, 4, 10 );
Print_list (head );
Head = delete_node (Head, 12 );
Print_list (head );
Head = reverse_list (head );
Print_list (head );
}