/* HELLO.C -- Hello, world */
#include "stdio.h"
#include "conio.h"
typedef int DataType;
  typedef struct LNode
  {DataType data;
    struct LNode *next;
    }LNode,*LinkedList;
LinkedList LinkedListInit()         /*初始化链表  */
{ L=(LNode*)malloc(sizeof(LNode));
  if(L==null)
  {printf("Not enough space!");
    exit(0);
    }
    L->next=null;
    return L;
    }
Void LinkedListClear(LinkedList L) /*清空单链表  */
{P=L;int Q;
  while(P->next)
       {Q=P->next;
        P->next=Q->next;
        free(Q);
        }
int LinkedListEmpty(LinkedList L)   /*检查是否为空表*/                                   */
{if(L->next==null)
   printf("empty!");
   return 1;
  else printf("Not empty!");
       return 0;
       }
 void LinkedListTraverse(LinkedList L)  /*遍历单链表*/
 {P=L;
 while(P->next)
      {printf("%c",P);
       P=P->next;
       }
  }
 int LinkedListLength(LinkedList L)  /*求长度  */
 {  P=L->next;j=0;
    while(P->next)
     {j++;P=P->next;}
      return j;
      }
 LinkedList LinkedListGet(LinkedList L,int i)  /*按序查找   */
 {P=L->next;j=1;
   while(P!=null&&j<i)
        {P=P->next;
          j++;
          }
   if(j==i)
     return P;
   else return null;
   }
 LinkedList LinkedListLocate(LinkedList L,DataType x) /*按值查找  */
 { P=L->next;j=1;
   if(P!=null&&P->data!=x)
      {P=P->next;j++;
      }
   if(p->next==x)return j;
     else return 0;
     }
 void LinkedListInsert(LinkedList L,int i,DataType x)  /*在I之前插入元素X */
 {pre=L;
  while(pre!=null&&pre->next!=i)
  pre=pre->next;
  if(!pre){printf("The insert place is wrong!");exit(0);}
    S=(LNode*)malloc(sizeof(LNode)) ;
    S->data=x;
    S->next=pre->next;
    pre->next=S;
    }
 void LinkedListDel(LinkedList L,int i)  /*删除第I个节点  */
 {P=L;j=1;
   while(P->next&&j>i)
        {P=P->next;j++;}
   if(P->next==null||j>i)
   {printf("The point you want to delete is wrong!");
      exit(0);
      }
   Q=P->next;P->next=Q->next;free(Q);
   }
  LinkedList LinkedListCreat()
  { scanf(&x);
    while(x!=flag)
         {P=(LNode*)malloc(sizeof(LNode));
         P->data=x; r->next=P;r=P;
         scanf(&x);
         }
   r->next=null;return L;
   }
 main()
 {int n,i
   printf("Please input alphabet,ended with "flag"!");
   LinkedList LinkedListCreat();
   scanf(&n);
  switch(n)
  {case 1:LinkedListClear(LinkedList L);
           printf("The LinkedList has been cleared!");
   case 2:LinkedListEmpty(LinkedList l);
   case 3:LinkedListTravers(LinkedList L);
   case 4:printf("Please input the point you want to search!");
          scanf(&i);
          LinkedListGet(LinkedList L,int i);
   case 5:printf("Please input the alphabet you want to search!");
          scanf(&i);
          LinkedListLocate(LinkedList L;DataType x)
   case 6:printf("Please input the alhpabet you want to delete!");
          scanf(&x);
          LinkedListDel(LinkedList L,int i);
          }
 }

 
											





