 TechArena Community The set_symmetric_difference() function of C++

#1
 Gavyn Member 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
 Praetor Member 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
 Katty Member Join Date: May 2008 Posts: 2,008
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
 kelfro Member Join Date: Apr 2008 Posts: 2,001
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
 Zecho Member Join Date: May 2008 Posts: 2,293
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
 absolute55 Member 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 }```

 Thread Tools Search this Thread Show Printable Version Email this Page Search this Thread: Advanced Search Similar Threads for: "The set_symmetric_difference() function of C++" Thread Thread Starter Forum Replies Last Post c++ equivalent function to the c-function 'sprintf Dilbert Software Development 6 13-12-2011 04:03 PM c# function equivalent to gettime function in javascript Omaar Software Development 4 10-03-2010 10:44 PM How to pass function with parameters to another function in PHP? Linoo Software Development 5 27-02-2010 07:52 PM How does abstract function differs from virtual function? Maddox G Software Development 5 29-01-2010 11:32 AM Function keys don't function under windows XP GunFighter Hardware Peripherals 3 08-04-2009 11:07 PM

All times are GMT +5.5. The time now is 06:11 PM.