. 1 #include <stdio.h> 2 #include <stdlib.h> . 3 typedef int elemType; . 4 typedef struct LNode { . 5 elemType Data; . 6 struct LNode * Next; . 7 } LNode, * LinkList; . 8 // new head interpolation list . 9 LinkList CreatList1 (LinkList & L) 10 { . 11 LNode S *; int X; 12 is // lead node list 13 is L = (LinkList) the malloc ( the sizeof (LNode)); 14 L->next=NULL; 15 scanf("%d",&x); 16 while(x!=9999){ 17 s=(LNode*)malloc(sizeof(LNode)); 18 s->data=x; 19 s->next=L->next; 20 L->next=s; 21 scanf("%d",&x); 22 } 23 return L; 24 } 25 //Tail interpolation new list 26 is LinkList CreatList2 (LinkList & L) 27 { 28 int X; 29 L = (LinkList) the malloc ( the sizeof (LNode)); // the lead node list 30 LNode S *, R & lt * = L; 31 is Scanf ( " % D " , & X); 32 the while (X =! 9999 ) { 33 is S = (LNode *) the malloc ( the sizeof (LNode)); 34 is S-> Data = X; 35 R-> Next = S ; 36 S = R & lt; // R & lt point to the new node tail of 37 [ Scanf ( " % D " , & X); 38 is } 39 R-> Next = NULL; 40 return L; 41 is } 42 is // Find the node number by the value 43 is LNode getElem * (L LinkList, int I) 44 is { 45 int J = . 1 ; 46 is LNode * = L-P> Next; 47 IF (I == 0 ) return L; 48 IF (I < . 1) return NULL; 49 while(p&&j<i){ 50 p=p->next; 51 j++; 52 } 53 return p; 54 } 55 //按值查找 56 LNode *LocateElem(LinkList L,ElemType e) 57 { 58 LNode *p=L->next; 59 while(p!=NULL&&p->data!=e){ 60 p=p->next; 61 } 62 return p; 63 } 64 // new node is inserted into the i-th position 65 BOOL ListFrontInsert (LinkList L, int i, elemType E) 66 { 67 LinkList getElem P = (L, I- . 1 ); 68 IF (P == NULL) return to false ; 69 // newly inserted node application space 70 LinkList S = (LNode *) the malloc ( the sizeof (LNode)); 71 is S-> Data = ; E 72 Next = p-S->> Next; 73 is p-> = Next S; 74 return to true ; 75 } 76 // delete the i-th node 77 BOOL ListDelete (LinkList L, int i) 78 { 79 LinkList getElem P = (L, I- . 1 ); 80 IF (P == NULL) return to false ; 81 LinkList Q; 82 = p-Q> Next; 83 p-> = Q- Next> Next; 84 Free (Q); 85 return to true ; 86 } 87 // print the value of each linked list node 88 void printlist (LinkList L) 89 { 90 L = L-> Next; 91 is the while (! L = NULL) { 92 the printf ( " % 3D " , L-> Data); 93 L = L-> Next; 94 } 95 the printf ( " \ n- " ); 96 } 97 int main () 98 { 99 LinkList L; 100 LinkList Search; 101 // new list head interpolation method, input data may be 9999. 7. 6. 5. 4. 3 102 // CreatList1 (L); 103 //The new end of the list interpolation, the input data may be. 3. 4. 5. 6. 7 9999 104 CreatList2 (L); 105 printlist (L); 106 Search = getElem (L, 2 ); 107 IF (! Search = NULL) { 108 the printf ( " Search by number success \ n- " ); 109 the printf ( " % 3D \ n- ' , Search-> Data); 110 } 111 Search LocateElem = (L, . 6 ); 112 IF ! (Search = NULL) { 113 the printf ( " by value to find success \ the n- " ); 114 the printf ( " % 3D \ n- " , Search-> Data); 115 } 1 16 ListFrontInsert (L, 2 , 99 ); 117 printlist (L); 1 18 ListDelete (L, . 4 ); 119 the printf ( " Delete fourth junction successful point \ n- " ); 120 printlist (L); 121 System ( " PAUSE " ); 122 }