文章

1

粉丝

0

获赞

7

访问

473

头像
链表合并 题解:
P1025 贵州大学机试题
发布于2025年3月3日 18:55
阅读数 473

#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;


//1025链表合并
struct node{
    int data;
    struct node *next;   
};


int main(){
    int m,n;
    cin>>m;
    struct node *headM, *headN;
    headM=new node;
    headN=new node;
    headM->next=NULL;
    headN->next=NULL;
    struct node *pm=headM;
    struct node *pn=headN;

    for(int i=0;i<m;i++){
        struct node *q=new node;
        q->next=NULL;
        cin>>q->data;
        pm->next=q;
        pm=q;        
    }

    cin>>n;
    for(int i=0;i<n;i++){
        struct node *q=new node;
      &nb...

登录查看完整内容


登录后发布评论

暂无评论,来抢沙发