求兩個鍊錶的並集

2021-07-05 15:18:22 字數 682 閱讀 7344

這學期剛剛學的資料結構  老師布置的作業 。寫寫看。

#include #include #define len sizeof(struct list)

struct list;

struct list * creat()//定義函式,此函式返回乙個指向煉表頭的指標

p2->next=null;

return head;

}//判斷第b鍊錶中的元素是否出現在a鍊錶中

bool notexit_a(int y,struct list *head)

//遍歷鍊錶a未找到相同的元素 返回true

return true;

}int main()

while(head_b!=null)

head_b=head_b->next;

} //釋放鍊錶b空間

while(head_temp1!=null)

free(relea),free(head_temp1);

printf("鍊錶a和b的並集為:");

雜湊 4 求兩個鍊錶的交集以及並集

目錄 1.簡單方法 2.使用歸併排序 3.使用雜湊 給定兩個鍊錶,求它們的交集 intersection 以及並集 union 用於輸出的list中的元素順序可不予考慮。例子 輸入下面兩個鍊錶 list1 10 15 4 20 list2 8 4 2 10 輸出鍊錶 交集list 4 10 並集li...

求兩個有序鍊錶的交集和差集

typedef struct listnode listnode 交集 注意 list1和list2如果各有2個4,交集也會出現兩次 listnode intersection listnode plist1,listnode plist2 頭結點 哨兵位節點 listnode newlist bu...

求兩個List的交集和並集

最近遇到的面試題,假設有兩個list分別為list1和list2 交集 list1.retainall list2 list1的資料就變成list1和list2的交集,list2不變。public class listtest system.out.println for int i 0 i lis...