C#的并集差集交集

1 //Intersect 交集,Except 差集,Union 并集
2             int[] a = { 1, 2, 3, 4, 5 ,6};
3             int[] b = { 2, 4, 5,6, 7, 8, 9 };
4             var jiaoJi = a.Intersect(b).ToList();//交集:2,4,5,6
5             var aChaJi = a.Except(b).ToList();//差集:1,3
6             var bChaJi = b.Except(a).ToList();//差集:7,8,9
7             var bingJi = a.Union(b).ToList();//并集:1,2,3,4,5,6,7,8,9

 

上一篇:mooc openjudge 014 MyString对运算符重载的综合使用


下一篇:014 java一维数组求最大值与最小值