文章

5

粉丝

34

获赞

0

访问

1.0k

头像
链表合并 题解:
P1025 贵州大学2019机试
发布于2024年3月27日 22:28
阅读数 157

每日一题  c语言

#include<stdio.h>
typedef struct Node{
    int num;
    struct Node *Next;
}node;

void Meg(node **head,node *L1,node *L2){
    node *ptr,*h;
    ptr = (node *) malloc(sizeof (node));
    h = (node *) malloc(sizeof (node));
    h = *head;
    L1 = L1->Next;
    L2 = L2->Next;
    while(L1 && L2){
        if(L1 ->num < L2 ->num){
            ptr = L1;
            L1 = L1->Next;
        }else{
            ptr = L2;
            L2 = L2->Next;
        }
        h ->Next = ptr;
        h = h->Next;
    }
    if(L1){
        h->Next=L1;
    } else
...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发