Problem:- Construct a 6 input gate which performs the following logical operation:
(not(A)).B + C.D +E.(not(F))
where A, B, C, D, E, and F are the inputs to the 6 input gate.
Input:
The first line of input takes the number of test cases, T. Then T test cases follow. Each test case takes 6 space separated integers denoting the inputs to the 6 input gate, A, B, C, D, E, and F.
Note: the inputs can be either 1's or 0's.
Output:
Print the output of the 6 input gate for each test case on a new line.
Submit Your Solution Click Here
Solution:-
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b,c,d,e,f,x,y,z,res;
cin>>a>>b>>c>>d>>e>>f;
res=((!a)&b|c&d|e&(!f));
cout<<res<<endl;
}
return 0;
}
Output:-
(not(A)).B + C.D +E.(not(F))
where A, B, C, D, E, and F are the inputs to the 6 input gate.
Input:
The first line of input takes the number of test cases, T. Then T test cases follow. Each test case takes 6 space separated integers denoting the inputs to the 6 input gate, A, B, C, D, E, and F.
Note: the inputs can be either 1's or 0's.
Output:
Print the output of the 6 input gate for each test case on a new line.
Submit Your Solution Click Here
Solution:-
#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int a,b,c,d,e,f,x,y,z,res;
cin>>a>>b>>c>>d>>e>>f;
res=((!a)&b|c&d|e&(!f));
cout<<res<<endl;
}
return 0;
}
Output:-
0 Comments: