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);
}
|