#include <bits/stdc++.h>
#define ElemType char
using namespace std;
typedef struct LNode{
ElemType data;
struct LNode* next;
}LNode, *LinkList;
LinkList createHeadList(vector<ElemType> data) {
if (data.size() == 0) return NULL;
LNode* head = (LinkList)malloc(sizeof(LNode));
head->next = NULL;
LNode* p = head;
for (int i = 0; i < data.size(); i++) {
LNode* q = (LNode*)malloc(sizeof(LNode));
q->data = data[i];
q->next = NULL;
p->next = q;
p = q;
}
return head;
}
void printList(LinkList L) {
while (L != NULL) {
cout << L->data;
L = L->next;
}
puts("");
}
int main() {
vector<char> dataA{'l', 'o', 'a', 'd'};
vector<char> dataB{'b', 'e'};
vector<char> dataC{'i', 'n', 'g'};
LinkList headA = createHeadList(dataA);
LinkList headB = createHeadList(dataB);
LinkList headC = createHeadList(dataC);
LNode *p1 = headA->next, *p2 = headB->next, *p3 = headC->next;
while (p1->next != NULL) p1 = p1->next;
while (p2->next != NULL) p2 = p2->next;
p1->next = p3;
p2->next = p3;
cout << "链表A: ";
printList(headA->next);
cout << "链表B: ";
printList(headB->next);
return 0;
}