/// @brief 删除两个链表中相同的元素 /// 1、取A链表中第一个元素,遍历A,B链表有相同的元素就删除。 /// 2、取A中下一个元素,重复1操作,直到取完A中所有元素。 #include <stdio.h> typedef struct Node { int data; Node *next; Node *prev; }Node; Node *CreatList() { int data = 0; Node *tmp = NULL; Node *current = NULL; Node *head= (Node *)malloc(sizeof(Node)); head->data = 0; head->next = NULL; head->prev = NULL; tmp = head; while(1) { fprintf(stdout,"please input list element:"); scanf(&data); if(0 == data) { fprintf(stdout,"thank for you input is over and you have a list now\n"); break; } else { current = (Node *)malloc(sizeof(Node)); current->data = data; current->next = tmp; tmp->prev = current; current->prev = head; head->next = current; tmp = current; } } return head; } void eraseTowListEqualElem(Node* L1,Node* L2) { }
|
|
来自: 海漩涡 > 《my program》