# Include <stdio. h>
# Include <malloc. h>
Typedef struct Node {
Int data;
Struct Node * next;
} Node, * Link;
Node * init (int len) // initialize the linked list
{
Int I;
Node * head, * p, * q;
Head = (Link) malloc (sizeof (Node ));
P = head;
For (I = 0; I <len; I ++)
{
Q = (Link) malloc (sizeof (Node ));
Q-> data = 2 * I;
Q-> next = NULL;
P-> next = q;
P = q;
Head-> data ++;
}
Return head;
}
Node * insert (Node * hm, int x) // insert a Node
{
Node * m, * tmp;
M = hm-> next;
Tmp = (Link) malloc (sizeof (Node ));
Tmp-> data = x;
Tmp-> next = NULL;
While (m-> next! = NULL)
{
If (x> m-> data & x <= m-> next-> data)
{
Tmp-> next = m-> next;
M-> next = tmp;
Hm-> data ++;
}
M = m-> next;
}
If (x> m-> data)
{
M-> next = tmp;
Hm-> data ++;
}
Return hm;
}
Node * delete (Node * hm, int x) // delete a Node
{
Int bool = 0;
Node * m, * tmp;
M = hm;
While (m-> next! = NULL)
{
If (m-> next-> data = x)
{
Tmp = m-> next;
M-> next = tmp-> next;
Free (tmp );
Bool = 1;
Hm-> data --;
}
If (m! = NULL)
{M = m-> next ;}
If (m = NULL) {break ;}
}
If (bool = 0) {printf ("there is no this kind of node: % d \ n", x );}
Return hm;
}
// Linked list reverse http://blog.csdn.net/niuer09/article/details/5961004
Node * reverse (Node * hm) // reverse sequence of the linked list
{
If (hm-> next = NULL | hm-> next = NULL)
{Return hm ;}
Node * t = NULL, * p = hm-> next, * q = p-> next;
While (q! = NULL)
{
T = q-> next;
Q-> next = p;
P = q;
Q = t;
}
Hm-> next = NULL;
Hm-> next = p;
Return hm;
}
Void play (Node * m) // print the Node
{
While (m! = NULL)
{
Printf ("% d", m-> data );
M = m-> next;
}
Printf ("\ n ");
}
Void main (int argc, char * argv [])
{
Int len, insertnum, deletenum;
Node * l;
Len = atoi (argv [1]);
Insertnum = atoi (argv [2]);
Deletenum = atoi (argv [3]);
L = init (len );
L = insert (l, insertnum );
Play (l );
}