Given three arrays A[n], B[n] & C[n] containing bit strings representing sets A, B & C respectively, write a code fragment to determine whether (̅∩ ) ⊂ ̅
#include<bits/stdc++.h>
using namespace std;
//Declaring function doXor with 3 parameters
string doXor(string A, string B, int len){
string ans = "";
for (int i = 0; i < len; i++)//for loop till the length of the variable
{
if (A[i] == B[i])// doing xor of the variables
ans += "0";
else
ans += "1";
}
return ans; // returning the value of xor
}
int main()
{
string A = "1010";
string B = "1101";// Declaring two string with binary value
int len = A.length();
//storing the length of any one variable as lenghth is sae of both
string c = doXor(A, B, len);//calling and passing argument in function
cout <<"Xor of the two string is : "<< c << endl;//printing the value of xor
}
Comments
Leave a comment