lc86-分隔链表

linklist *partition(linklist *head,int x){
    linklist *head1,*head2,*q=head->next;
    head1=(linklist*)malloc(sizeof(linklist));
    head2=(linklist*)malloc(sizeof(linklist));
    linklist *l1=head1,*l2=head2;
    head2->next=NULL;
    while(q){
        if(q->datanext=q;
            q=q->next;
            l1=l1->next;
            l1->next=NULL;
        }
        else{
            l2->next=q;
            q=q->next;
            l2=l2->next;
            l2->next=NULL;
        }
    }
    l1->next=head2->next;
    return head1;
}

你可能感兴趣的:(lc86-分隔链表)