#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int data;
struct node* next;
}Node;
void CreatList(Node* head, int a) {
Node* temp;
temp = (Node*)malloc(sizeof(Node));
temp = head;
for (int i = 0; i < a; i++) {
temp->next = (Node*)malloc(sizeof(Node));
scanf("%d", &temp->next->data);
temp = temp->next;
}
temp->next = NULL;
}
void Function(Node* head1, Node* head2, Node* head3) {
Node *temp1, *temp2, *temp3;
temp1 = head2->next;
temp2 = head3->next;
temp3 = head1;
int A[100] = { -999999999 }, i = 0, j = 1;
//找出head2和head3中的相同元素
while (temp2 && temp1) {
while (temp2 != NULL && temp1 != NULL && temp1->data != temp2->data) {
if (temp1->data > temp2->data) {
temp2 = temp2->next;
}
else {
temp1 = temp1->next;
}
}
if (temp1 == NULL || temp2 == NULL) {
break;
}
else {
A[i+1] = temp1->data;
temp1 = temp1->next;
temp2 = temp2->next;
i++;
}
}
//去除head1中的元素
while (temp3->next) {
if (A[j] == 0 && temp3->next != NULL) {
break;
}
while (temp3->next->data < A[j] && temp3->next != NULL) {
temp3 = temp3->next;
printf("%d",temp3);
}
if (temp3->next->data == A[j] && temp3->next != NULL) {
Node* p = temp3->next;
temp3->next = p->next;
free(p);
}
j++;
}
}
void Print(Node* head) {
Node* p = head->next;
while (p) {
printf("%d ", p->data);
p = p->next;
}
}
int main()
{
int m, n, p;
struct node* head1 = NULL, *head2 = NULL, *head3 = NULL;
head1 = (Node*)malloc(sizeof(Node));
head2 = (Node*)malloc(sizeof(Node));
head3 = (Node*)malloc(sizeof(Node));
scanf("%d%d%d", &m, &n, &p);
CreatList(head1, m);
CreatList(head2, n);
CreatList(head3, p);
Function(head1, head2, head3);
Print(head1);
return 0;
}