Please help

Hey guys I got an assigment due but not sure how to do it, could you guys help me out?

A set is an unordered collection of distinct elements of the same type. For example,
A = {4,2,0,-1,23,17} is a set of 6 integers.
Recall from basic math that Set operations include membership, union, intersection, cardinality (and others..),

x  A : is x a member of set A?
A  B: A union B is the set of all elements that are either in A or in B or in both.
A  B: A intersection B is the set of all elements that are in both sets A and B.

For the sake of this assignment, sets will be represented by Arrays.
Write a program that initializes two sets with input from the user, then builds a new set containing their Union and another set containing their Intersection. (Note: The two functions to perform the Union and Intersection will probably need to call a function that tests on membership).
The program ends by printing both original sets, with their Union and their intersection.

You can use the following skeleton for your program:

void makeSet(int aSet[], int &size);
bool member (int el, int aSet[], int size);
void unionSet(int setA[], int a, int setB[], int b, int unionAB[], int &uab);
void intersection(int setA[], int a, int setB[], int b, int intersAB[], int &iab);
void printSet (string setName, int aSet[], int size)

int main(){
const int MAX = 10;
int setA[MAX]; // declaring a set of max size 10
int setB[MAX]; // declaring a second set of max size 10
int unionAB[2*MAX]; // declaring a set that will contain the Union
int intersAB[MAX]; // declaring a set that will contain the intersection
int a, b, uab, iab; // declaring the actual sizes of all 4 sets

makeSet(setA, a); // filling the first set and determining its size
makeSet(setB, b); // filling the second set and determining its
unionSet(setA,a, setB, b,unionAB,uab); // find the Union set and its size
intersection(setA,a, setB,b, intersAB,iab); // find the Intersection set & its size

// Printing all 4 sets
printSet("A", setA, a);
printSet("B", setB, b);
printSet("A Union B", unionAB, uab);
printSet("A Intersection B", intersAB, iab);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <iostream>

using namespace std;

void makeSet(int aSet[], int &size){
    cout<<"Please enter the size" <<endl;
    cin >> size;
    cout << "Please enter " <<size <<" Elements" <<endl;
    for (int i=0; i<size;i++)
    cin >> aSet[i];
    }

bool member (int el, int aSet[], int size){
   bool tri=false;
   for (int j=0; j<size; j++){

        if(el= aSet[j])
            tri=true;

        }
    if (tri=true)
    cout<< el << " is a member of the set" <<endl;
    else cout << el << " is not a member of the set" <<endl;
}












void unionSet(int setA[], int a, int setB[], int b, int unionAB[], int &uab){
    int el;
    member (el,setA, a);
    member (el,setB,b);



}

void intersection(int setA[], int a, int setB[], int b, int intersAB[], int &iab){}
void printSet (string setName, int aSet[], int size){}

int main(){
   const int MAX = 10;
   int setA[MAX];   // declaring a set of max size 10
   int setB[MAX];   // declaring a second set of max size 10
   int unionAB[2*MAX];   // declaring a set that will contain the Union
   int intersAB[MAX];  // declaring a set that will contain the intersection
   int a, b, uab, iab;  // declaring the actual sizes of all 4 sets

   makeSet(setA, a);  // filling the first set and determining its size
   makeSet(setB, b);  // filling the second set and determining its
   unionSet(setA,a, setB, b,unionAB,uab);  // find the Union set and its size
   intersection(setA,a, setB,b, intersAB,iab); // find the Intersection set & its size

   // Printing all 4 sets
   printSet("A", setA, a);
   printSet("B", setB, b);
   printSet("A Union B", unionAB, uab);
   printSet("A Intersection B", intersAB, iab);
}
Topic archived. No new replies allowed.