# Include
# Include
Typedef char DataType; typedef struct node {DataType data; struct node * next;} ListNode; typedef ListNode * LinkList; ListNode * p; LinkList head; LinkList CreatList (void) // create a linked list {char ch; LinkList head; ListNode * s, * r; head = (LinkList) malloc (sizeof (ListNode); r = head; while (ch = getchar ())! = '\ N') {s = (ListNode *) malloc (sizeof (ListNode); s-> data = ch; s-> next = s; r = s ;} r-> next = NULL; return head;} ListNode * GetNode (LinkList head, int I) // query by serial number {int j; ListNode * p; p = head; j = 0; while (p-> next & j
Next; j ++;} if (I = j) return p; elsereturn NULL;} void InsertList (LinkList head, DataType x, int I) // insert {ListNode * p; ListNode * s; p = GetNode (head, I-1); if (p = NULL) printf ("position error! "); S = (ListNode *) malloc (sizeof (ListNode); s-> data = x; s-> next = p-> next; p-> next = s;} void DeleteList (LinkList head, int I) // Delete {ListNode * p, * r; p = GetNode (head, I-1 ); if (p = NULL | p-> next = NULL) printf ("position error"); r = p-> next; p-> next = r-> next; free (r );}