Trộn 2 ds lk tăng

Màu nền
Font chữ
Font size
Chiều cao dòng

struct node *tron_ds(struct node *f1, struct node *f2){ 

    struct node *p, *q, *f; 

    f = NULL; 

    p=f1; q=f2; 

    while(p!=NULL && q !=NULL){ 

        if(p->info.masv <= q->info.masv){ 

            f = them_cuoi(f, p->info); 

            p = p->next; 

        } 

        else{ 

            f = them_cuoi(f, q->info); 

            q= q->next; 

        } 

    } 

    if(p==NULL){ 

        while(q != NULL){ 

            f = them_cuoi(f,q->info); 

            q = q->next; 

        } 

    } 

    else if(q==NULL){ 

        while(p != NULL){ 

            f = them_cuoi(f,p->info); 

            p = p->next; 

        } 

    } 

    return f; 

}  

Bạn đang đọc truyện trên: Truyen2U.Pro