文章

5

粉丝

0

获赞

0

访问

1.6k

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

#include<stdio.h>
#include<stdlib.h>
typedef struct node{
    int date;
    struct node *next;
}*LinkList,Lnode;

LinkList creat(int a[], int n){
    int i;
    Lnode *p;
    LinkList head = (LinkList)malloc(sizeof(Lnode));
    head->next = NULL;
    for(i=n-1;i>=0;i--){
        p = (Lnode*)malloc(sizeof(Lnode));
        p->date = a[i];
        p->next = head->next;
        head->next = p;
    }
    return head;
}

//和归并排序merge思想类似的
LinkList merge(LinkList L1, LinkList L2){
    LinkList L,p;
    L = (LinkList)malloc(sizeof(Lnode));
    L->next = NULL;
    p=L;
    L1 = L1->next;
   &nbs...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发