#include <stdio.h>
#include <stdlib.h>
typedef int Elemtype;
typedef struct C
{
Elemtype data;
struct C *next;
} CNode, *CLink;
CLink Connect(CLink a, CLink b)
{
CLink p = a->next;
a->next = b->next->next;
free(b->next);
b->next = p;
return b;
}
void Display(CLink L)
{
CLink p = L->next;
while (p != L)
{
printf("%d ", p->data);
p = p->next;
}
printf("\n");
}
CLink RCreate(int n)
{
CLink L = (CLink)malloc(sizeof(CNode));
// L->data = 0;
L->next = NULL;
CLink r = L; //创建尾结点
for (int i = 0; i < n; i++)
{
CLink p = (CLink)malloc(sizeof(CNode));
scanf("%d", &p->data);
//p->next = NULL;
r->next = p; //将新结点链接到表尾
r = p; //循环过程中r始终指向链表的尾结点
}
r->next = L;
return L;
}
int main()
{
CLink a = RCreate(4);
Display(a);
Display(a);
CLink b = RCreate(3);
Display(b);
CLink c = Connect(a, b);
Display(c);
Display(b);
return 0;
}
没有悬赏没人答吗?也不是不想充,一次充值100学生党承受不起啊