数据结构,关于不带头结点的单链表问题,求大神们解答,万分感谢,急用,真的很急!

2025-04-03 16:05:42
推荐回答(1个)
回答1:

typedef struct Node
{
int data;
struct Node *next;
}Node; //这里结构体的定义视你的需要自己换

void Fun(Node **heada,Node **headb,int i,int j,int len)
{
Node *p,*q,*r;
p = *heada;
q = *heada;
int n = 1;
while(n++ < i)
p = p->next;
q = p->next;
n = 0;
while(n ++ < len && q)
q = q->next;
r = p->next;
p->next = q->next;
q->next = NULL;
n = 1;
p = *headb;
while(n++ p = p->next;
q->next = p->next;
p->next = r;
}
程序里面没有考虑你的参数不合理的情况