两个整数集合采用递增有序单链表存储,设计尽可能高效的算法求两个集合的并集。
输入
主函数直接设定两个整数集合,测试数据包括:
(1)
ElemType a[]={1,3,6,8,10,20};
ElemType b[]={2,5,6,10,16,20,30};
(2)
ElemType a[]={1,2,3,4};
ElemType b[]={3,4,5,6,8};
(3)
ElemType a[]={1,2};
ElemType b[]={8,9,10,11};
(4)
ElemType a[]={};
ElemType b[]={1};
(5)
ElemType a[]={0};
ElemType b[]={};
输出
整数集合并集
样例输入
以第一组(1)为例。无输入。
样例输出
1 2 3 5 6 8 10 16 20 30