Results 1 to 6 of 6

Thread: The set_symmetric_difference() function of C++

  1. #1
    Join Date
    Dec 2009
    Posts
    31

    The set_symmetric_difference() function of C++

    I am interested in doing the programming. Thus, I had just started for learning the C++ programming language. I can also have the knowledge of the basic working of the functions. Hence, I want to know what is the set_symmetric_difference() function of the C++ language. I also want to know what is the use of the set_symmetric_difference() function in the C++ programming. Can anyone knows about the set_symmetric_difference() function of C++ language.

  2. #2
    Join Date
    Apr 2008
    Posts
    1,948

    The set_symmetric_difference()

    The set_symmetric_difference() function of the C++ language can be used for the difference that can be symmetric of the two given specified ranges that can be sorted. The set_symmetric_difference() function can constructs a sorted range that can be starting in the place that can be pointed by the rslt with the set of difference that can be symmetric of the two given specified ranges such as the range [fst1,lst1) and the range [fst2,lst2) that can be sorted as content. The set_symmetric_difference() function can be comes under the algorithm header files.
    Last edited by Praetor; 05-03-2010 at 03:44 PM.

  3. #3
    Join Date
    May 2008
    Posts
    2,012

    The set_symmetric_difference() function of C++

    The set_symmetric_difference() function of the C++ language can be used to create the symmetric difference between the two given ranges. The following can be the general form of the set_symmetric_difference() function in the C++ language :
    Code:
    template <class InptItrtr1, class InptItrtr2, class OtptItrtr>
      OtptItrtr
        set_symmetric_difference ( InptItrtr1 fst1, InptItrtr1 lst1,
                                   InptItrtr2 fst2, InptItrtr2 lst2,
                                   OtptItrtr rslt );

  4. #4
    Join Date
    Apr 2008
    Posts
    2,005

    set_symmetric_difference()

    The following program can demonstrates you how to implement the set_symmetric_difference() function of the C++ language in the C++ programming as follows :
    Code:
    #include <iostream>
    #include <algorithm>
    #include <vector>
    using namespace std;
    int main () 
    {
      int ft[] = {5,10,15,20,25};
      int sd[] = {50,40,30,20,10};
      vector<int> v(10);    
      vector<int>::iterator i;
      sort (ft,ft+5);    
      sort (sd,sd+5);
      i=set_symmetric_difference (ft, ft+5, sd, sd+5, q.begin());
      cout << "symmetric difference has " << int(i - q.begin()) << " elements.\n";
      return 0;
    }
    Output:
    Code:
    symmetric difference has 6 elements

  5. #5
    Join Date
    May 2008
    Posts
    2,297

    The set_symmetric_difference() function of C++

    The following can be the parameters of the set_symmetric_difference() function in the C++ language :
    1. fst2, lst2 : These parameters of the set_symmetric_difference() function can contains an input iterators to the final and starting positions of the given second sequence. The range used can be as [fst2,lst2).
    2. fst1, lst1 : These parameters of the set_symmetric_difference() function can contains input iterators to the final and starting positions of the given first sequence. The range used can be as [fst1,lst1) that can contains all of an elements that can be between fst1 and lst1.

  6. #6
    Join Date
    Nov 2005
    Posts
    1,323

    Re: The set_symmetric_difference() function of C++

    PROGRAM :
    Code:
         #include<algorithm>
         #include<set>
         #include <istream.h>
         using namespace std;
         int main()
          {
         int B1[] = {1,3,5,7,9,11};
         int B3[] = {3,5,7,8};
         set<int, less<int> > od(B1+0,B1+6), rslt,
            small(B3+0,B3+4);
         insert_iterator<set<int, less<int> > >
            res_ins(rslt, rslt.begin());
         cout << "The symmetric difference of:" << endl << "{";
         copy(small.begin(),small.end(),
             ostream_iterator<int,char>(cout," "));
         cout << "} with {";
         copy(od.begin(),od.end(),
             ostream_iterator<int,char>(cout," "));
         cout << "} =" << endl << "{";
         set_symmetric_difference(small.begin(), small.end(),
                                 od.begin(), od.end(), res_ins);
         copy(rslt.begin(),rslt.end(),
             ostream_iterator<int,char>(cout," "));
         cout << "}" << endl << endl;
         return 0;
          }
    Program Output :
    Code:
         The symmetric difference of:
         {3 5 7 8 } with {1 3 5 7 9 11 } =
         {1 8 9 11 }

Similar Threads

  1. c++ equivalent function to the c-function 'sprintf
    By Dilbert in forum Software Development
    Replies: 6
    Last Post: 13-12-2011, 04:03 PM
  2. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  3. Replies: 5
    Last Post: 27-02-2010, 07:52 PM
  4. How does abstract function differs from virtual function?
    By Maddox G in forum Software Development
    Replies: 5
    Last Post: 29-01-2010, 11:32 AM
  5. Function keys don't function under windows XP
    By GunFighter in forum Hardware Peripherals
    Replies: 3
    Last Post: 08-04-2009, 11:07 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,241,968.63183 seconds with 17 queries