c语言单链表按基准值划分


#include
#include
#include
typedef struct LinkNode
{
    int data;
    struct LinkNode *next;
}LinkNode;
void InitList(LinkNode *&L)
{
    L=(LinkNode*)malloc(sizeof(LinkNode));
    L->next=NULL;
}
void CreatList(LinkNode *&L,int a[],int n)
{
    LinkNode *s;
    L=(LinkNode*)malloc(sizeof(LinkNode));
    L->next=NULL;
    for(int i=0;idata=a[i];
        s->next=L->next;
        L->next=s;
    }
}
void DisList(LinkNode *L)
{
    LinkNode *p=L->next;
    while(p!=NULL)
    {
        printf("\t%d",p->data);
        p=p->next;
    }
    printf("\n");
}
bool panduan(LinkNode *L,int num)
{
    int i=1;
    LinkNode *p=L->next;
    while(p!=NULL&&p->data!=num)
    {
        p=p->next;
        i++;
    }
    if(p==NULL)
    {
        return false;
    }
    else
    {
        return true;
    }
}
void sort(LinkNode *L,int num,bool dui)
{
    LinkNode *p=L->next,*t=NULL,*h=NULL,*s=NULL;
    L->next=NULL;
    if(dui==true)
    {
        while(p)
    {
        t=p;
        p=p->next;
        t->next=NULL;
        if(!L->next)
        {
            L->next=t;
        }
        else if (t->data>num)
        {
            h=L;
            while(h->next)
            {
                h=h->next;
            }
            h->next=t;
        }
        else{
            h=L->next;s=L;
            while(h&&h->datas=h,h=h->next;
            }
            if(s==L)
            {
                t->next=L->next;
                L->next=t;
            }
            else
            {
                t->next=s->next;
                s->next=t;
            }
        }
    }
    DisList(L);
    }
    else{
        printf("ERROR input");
    }
    }

int main()
{
    int n,e[100];
    int x;
    LinkNode *L;
     InitList(L);
    scanf("%d",&n);
    for(int i=0;i"%d",&e[i]);
    }
    scanf("%d",&x);
    bool dui;
    dui=panduan(L,x);
    CreatList(L,e,n);
    DisList(L);
    sort(L,x,dui);
    return 0;

}

这是题目:

img


为什么我的结果一直是这样好伤心:

img


也不知道到底哪里错了