fork download
  1. #include <iostream>
  2. #include <set>
  3.  
  4. using std::set;
  5. using std::cout;
  6. using std::endl;
  7.  
  8. int main() {
  9.  
  10. int A[4] = { 0, 1, 2, 3 };
  11. int B[6] = { 2, 3, 4, 5, 5, 6 };
  12. int C[5] = { 5, 6, 7, 8, 9 };
  13.  
  14. set<int> AB;
  15. set<int> BC;
  16. set<int> CA;
  17. set<int> ABC;
  18.  
  19. AB.insert( A, A + 4 );
  20. AB.insert( B, B + 6 );
  21.  
  22. BC.insert( B, B + 6 );
  23. BC.insert( C, C+ 5 );
  24.  
  25. CA.insert( C, C + 5 );
  26. CA.insert( A, A + 4 );
  27.  
  28. ABC.insert( A, A + 4 );
  29. ABC.insert( B, B + 6 );
  30. ABC.insert( C, C + 5 );
  31.  
  32. int maxSet = 0;
  33. size_t maxSize = AB.size();
  34.  
  35. if ( BC.size() > maxSize ) {
  36.  
  37. maxSize = BC.size();
  38. maxSet = 1;
  39.  
  40. }
  41.  
  42. if ( CA.size() > maxSize ) {
  43.  
  44. maxSize = CA.size();
  45. maxSet = 2;
  46.  
  47. }
  48.  
  49. if ( ABC.size() > maxSize ) {
  50.  
  51. maxSize = ABC.size();
  52. maxSet = 3;
  53.  
  54. }
  55.  
  56. cout << " Array Combination No. " << maxSet << " has MAX unique elements. " <<endl;
  57. cout << " The max number of unique elements = " << maxSize << endl;
  58.  
  59. return 0;
  60. }
Success #stdin #stdout 0s 3476KB
stdin
Standard input is empty
stdout
 Array Combination No. 3 has MAX unique elements. 
 The max number of unique elements = 10