1. /////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
// Brian Goggins
// 1/29/2015
// Cosc 281
// Homework 1
/////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////
#include <iostream>
using namespace std;
int A[] = { 9, 3, 5 };
int nA = 3;
int B[] = { 3, 4, 5, 6, 7, 8, 9 };
int nB = 7;
int C[] = { 0, 0, 0 };
int AorB[10];
int contained = 1;
int O = 0;
// Testing if A union B is equal to B
void or()
{
for (int i = 0; i < nA; i++)
{
for (int j = 0; j < nB; j++)
{
if (A[i] == B[j]){ AorB[j] = B[j]; }
if (A[i] != B[j]){ AorB[j] = B[j]; }
}
}
}
//Testing if A is contained in B
void contain()
{
for (int i = 0; i < nA; i++)
{
for (int j = 0; j < nB; j++)
{
if (A[i] == B[j]){ C[i] = 1; }
}
}
for (int i = 0; i < nA; i++)
{
if (C[i] == 0){ contained = 0; }
}
if (contained == 1){ or(); }
}
//Displays all sets and results of theorem testing
int main()
{
contain();
cout << "nA:";
for (int i = 0; i < nA; i++)
{
2. cout << A[i] << " ";
}
cout << "nB:";
for (int i = 0; i < nB; i++)
{
cout << B[i] << " ";
}
if(contained==1) cout << "nA is contained in B therefore A union B is equal to
Bn";
if(contained==0) cout << "nA is not contained in B and A union B is not equal to
Bn";
return 0;
}