0

I need to find the difference of 2 sets. below are my functions for the union and intersection of sets in my driver-file. Is the difference set a combination of the two?

IntegerSet IntegerSet::unionOfSets(IntegerSet b)
{
	IntegerSet c;

	for ( int i = 0; i < 101; i++ ) 
	{
		if ( set[i] || b.set[i] )
		c.set[i] = 1;
	}

	return( c );
}

IntegerSet IntegerSet::intersectionOfSets(IntegerSet b)
{
	IntegerSet d;
 
	for ( int i = 0; i < 101; i++ ) 
	{
		if ( set[i] && b.set[i] )
		d.set[i] = 1;
	}
 		return( d );
}
2
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by WaltP
0

Are you having a problem you're not telling us or just asking a strange question that's hard to decipher?

0

Are you having a problem you're not telling us or just asking a strange question that's hard to decipher?

im asking what the function would look like for the difference of sets

0

In your code:
The union uses OR
The intersection uses AND
I believe you'll find the difference uses XOR

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.