Exemple #1
0
 int main() {
 IntegerSet a;
 IntegerSet b;
 IntegerSet c;
 IntegerSet d;
  
 cout << "Enter set A:\n";
 a.inputSet();
 cout << "\nEnter set B:\n";
 b.inputSet();
 c = a.unionOfSets(b);
 d = a.intersectionOfSets(b);
 cout << "\nUnion of A and B is:\n";
 c.printSet();
 cout << "Intersection of A and B is:\n";
 d.printSet();
  
 if (a.isEqualTo(b))
 cout << "Set A is equal to set B\n";
 else
 cout << "Set A is not equal to set B\n";
  
 cout << "\nInserting 77 into set A...\n";
 a.insertElement(77);
 cout << "Set A is now:\n";
 a.printSet();
  
 cout << "\nDeleting 77 from set A...\n";
 a.deleteElement(77);
 cout << "Set A is now:\n";
 a.printSet();
  
 const int arraySize = 10;
 int intArray[ arraySize ] = { 25, 67, 2, 9, 99, 105, 45, -5, 100, 1 };
 IntegerSet e(intArray, arraySize);
  
 cout << "\nSet e is:\n";
 e.printSet();
  
 cout << endl;
 } // end main
Exemple #2
0
int main(){
	
	// Create objects
	IntegerSet A;
	IntegerSet B;
	IntegerSet C;

	// Fill sets
	cin >> A;
	cout << "\n\t" << A;
	cin >> B;
	cout << "\n\t" << B;

	// Increment and Decrement Test
	cout << "\n\tIncrementing each element in A" << endl;
	A = ++A;
	cout << "\n\t" << A << endl;

	cout << "\n\tDecrementing each element in B" << endl;
	B = --B;
	cout << "\n\t" << B << endl;

	// Mathematical functions
	C = A^B;
	cout << "\n\tThe intersection of Set A and Set B is: ";
	C.printSet();

	C = A+B;
        cout << "\n\tThe union of Set A and Set B is: ";
        C.printSet();

	C = A-B;
        cout << "\n\tThe difference of Set A and Set B is: ";
        C.printSet();

	bool equal = (A==B);
	if(equal)
		cout << "\n\tA and B are equal";

	cout << endl;
}