文章

17

粉丝

0

获赞

5

访问

1.3k

头像
链表合并 题解:只为锻炼手搓链表以及合并链表,代码越长就越容易出一些小问题,因此一定要细心
P1025 贵州大学机试题
发布于2025年5月16日 14:27
阅读数 69

#include<iostream>
using namespace std;

struct Node{
    int data;
    struct Node *next;
};

struct Node *create(int n){
    struct Node *head=nullptr,*p=nullptr;
    for(int i=0;i<n;i++){
        struct Node *now=(Node *)malloc(sizeof(Node));
        int num;
        cin>>num;
        now->data=num;
        now->next=NULL;
        if(head==nullptr){
            head=now;
        }
        else{
            p->next=now;
        }
        p=now;
    }
    return h...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发