Description recently Jerry is working hard to learn the function of set in STL, he found that set can be used in the existing functions to achieve and, intersection, difference, symmetry and other functions, but he did not find how to compare the two sets are equal function function, So he wants to use other functional functions to determine whether the two sets are equal. Clever Jerry will think of the solution, and now he wants to take this question to test you, to see if you have him smart.
Input
Input has multiple groups, each set of data has two rows, each row represents a collection, each row has several positive integers (0<d<=2147483647), and the last number of each row is 0, which represents the end of the row of data, and the end of 0 does not count toward the collection. Finally, end the input with EOF.
Output will enter a result for each set of data outputs, if the two sets are equal then outputs "YES", otherwise outputs "NO", each result occupies one row
Sample Input1 2 3 4 0 1 2 3 4 0 1 2 2 2 2 2 0 1 2 0 1 2 3 4 0 1 3 3 4 0Sample OutputYes Yes NOHINT
Symmetric difference Operation: The resulting result is the difference between the first set and the second set and the difference between the second and first
combine B and use the above tips to quickly ac!
Append Code
#include <iostream>#include<algorithm>#include<Set>using namespacestd;intMain () {intt,j; while(cin>>t) {Set<int>A; Set<int>B; Set<int>Tmp1,tmp2,tmp3; if(t!=0) {A.insert (t); while(cin>>t&&t!=0) A.insert (t); } while(cin>>t&&t!=0) B.insert (t); Set_difference (A.begin (), A.end (), B.begin (), B.end (), Inserter (TMP1, Tmp1.begin ())); Set_difference (B.begin (), B.end (), A.begin (), A.end (), Inserter (TMP2, Tmp2.begin ())); Set_union (Tmp1.begin (), Tmp1.end (), Tmp2.begin (), Tmp2.end (), Inserter (Tmp3, Tmp3.begin ())); if(Tmp3.empty ()) cout<<"YES"<<Endl; Elsecout<<"NO"<<Endl; } return 0;}
The problem of experimental 7:problem C:stl--jerry