GIDForums  

Go Back   GIDForums > Computer Programming Forums > C++ Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 04-Nov-2017, 10:12
john17 john17 is offline
New Member
 
Join Date: Nov 2017
Posts: 1
john17 is on a distinguished road

Check subset,union,intersection,difference and disjoint between two arrays


CPP / C++ / C Code:
#include<iostream>
#include<string>
using namespace std;

int main();
char arr[100];
char arrA[100];
char arrB[100];
void UniversalSet(string U)
{
char a;

cout << "Your Input:" << U << endl;
int len = U.length();
if(U[0]!= '{')
{
cout << "\nWRONG INPUT. Example:{H,3,l,l,0}\n";
main();
}
do{
for(int i=1;i<=U.length()-2;i++)
{
if (U[i]==',')
continue;
a = U[i] ;//<<' ';
arr[i] = a;
}

}while(0);
}
void SetA(string U)
{
char a;

cout << "Your Input:" << U << endl;
int len = U.length();
if(U[0]!= '{')
{
cout << "\nWRONG INPUT. Example:{H,3,l,l,0}\n";
main();
}
do{
for(int i=1;i<=U.length()-2;i++)
{
if (U[i]==',')
continue;
a = U[i] ;//<<' ';
arrA[i] = a;
}

}while(0);
}
void SetB(string str)
{
char a;

cout << "Your Input:" << str << endl;
//int len = str.length();
if(str[0]!= '{')
{
cout << "\nWRONG INPUT. Example:{H,3,l,l,0}\n";
main();
}
do{
for(int i=1;i<=str.length()-2;i++)
{
if (str[i]==',')
continue;
a = str[i] ;//<<' ';
arrB[i] = a;
}

}while(0);
}
int main()
{
string U,A,B;
int temp=0;
cout<<"Enter Input for Universal set U: "; getline(cin,U);
cout<<"Enter Input for set A: "; getline(cin,A);
cout<<"Enter Input for set B: "; getline(cin,B);
UniversalSet(U);
SetA(A);
SetB(B);


for(int i=1;i<100;i++)
{
cout << arr[i];
}
cout << endl;
for(int i=1;i<100;i++)
{
cout << arrA[i];
}
cout << endl;
for(int i=1;i<100;i++)
{
cout << arrB[i];
}




}


How can I check if the elements of arrA[] and arrB[] in arr[]?
If the elements of arrA[] and arrB[] is a subset of arr[] then how to check union,intersection,difference and disjoint between arrA[] and arrB[]?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDApp · GIDBlog · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 21:50.


vBulletin, Copyright © 2000 - 2017, Jelsoft Enterprises Ltd.