如下的题:
The symmetric difference of two sets is the set of elements belonging to one but not both of the two sets. For example, if we have two sets A = {1,2,3,4,5} and B = {3,4,5,6,7,8}, then the symmetric difference of A and B is the set {1,2,6,7,8}.
Given two sets of positive integers, display their symmetric difference.
Input
A positive integer will denote the number of cases. Both sets will be input from a single line. A zero (0) marks the end of each set. There will be no more than 20 numbers in each set, and no number within a set will be repeated. Each number in a set is a positive integer less than 65535.
Output
The set of integers making up the symmetric difference of the two sets. The numbers within a set may be sorted from smaller to bigger.
Sample Input
3
1 2 3 4 5 0 3 4 5 6 7 8 0
1 2 3 0 1 2 3 0
129 34 5 6 7 0 129 0
Sample Output
{1,2,6,7,8}
{}
{5,6,7,34}
其实求symmetric集我自己有几个办法:
1.并集-交集
2.(p-q)V(q-p) 也就是两个的差集的并集
可是这两个方法的实现都很麻烦,有没有更简单的实现呢?