//  线性表的基本操作  当我输入一组数字后为何不运行。希望帮忙改下
#include <iostream.h>
#include <malloc.h>
#include<stdio.h>
#include <stdlib.h>
#define Qelemtype char
#define sqlist L
#define NULL 0
#define LEN sizeof(struct Qnode)
#define error  char;
typedef struct Qnode
  {
    Qelemtype data;
     Qnode *next;
  } ;
  int n;
  struct Qnode  *initlist (void)
    {
      struct Qnode *L;
        L=(struct Qnode  *)malloc(LEN);
        L->next=NULL;
    }
    struct Qnode  *createlist(Qnode *L,int n)
    {
        int i;
        n=0;
        //initlist(&L);
        struct Qnode *p;
        //struct Qnode p;
        scanf("%c",&p->data);
        L=NULL;
        //s while(L->data!=0)
       // {n=n+1;
        //if(n==1)    L=p;
       //// else p->next=p;
        //p=L;
       // }
        for(i=n;i>0;i--)
        {
            p=(struct Qnode *)malloc(sizeof(Qnode));
            scanf("&p->data=%c",p->data);
            p->next=L->next;
            L->next=p;
        }
        return L;
    }
    char listinsert(Qnode *L,int i,Qelemtype e)
    {int j;
    struct Qnode *p,*s;
    p=L;
    j=0;
    while (p->next!=NULL&&j<i-1)
    {p=p->next;
    j++;
    }
   //if(!p&&j>i-1)
    //return error;
        //else
    s= (struct Qnode *)malloc(sizeof(Qnode));
    s->data=e;
    s->next=p->next;
    p->next=s;
    return s->data;
    }
    char listdelete(Qnode   *L,int i)
    {struct Qnode *p,*q;
    p=L;
    int j=0;
    Qelemtype e;
    while(p->next!=NULL&&j<i-1)
    {
        p=p->next;
        j++;
    }
    if(!p||j>i-1)  return -1;
    q=p->next;
    p->next=q->next;
    e=q->data;
    return q->data;
    free(q);
    }
    void display( Qnode *L,char * commemt)
    {struct Qnode *p;
    p=L->next;
    printf("输出结果如下\n");
    while(p)
    {
        printf("p->data=",p->data);
        p=p->next;
    }
    }
    void main()
    {
        struct Qnode *L;
        char e;
        char c;
        int i=0;
        initlist;
        printf("请输入你想要的数字");
        createlist(L,9);
        display(L,"the result");
        scanf("insert the number you want to insert%c",c);
        listinsert(L,6,c);
          display(L,"the result");
        listdelete(L,7);
          display(L,"the result");
    }

 
											





