homeworkhelp111

Boolean combination

Oct 19th, 2021 (edited)
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. void combination(bool A, bool B, bool C) {
  6.     if( (A && B ) || (A && C))
  7.         cout<< boolalpha << "("<< A <<" and " <<B <<") or ("<< A << " and "<<C<<") combination is true" <<endl;
  8.     if( (A && C ) && (B && C))
  9.         cout<< "("<< A <<" and " <<C <<") and ("<< B << " and "<<C<<") combination is true" <<endl;
  10.     if( (A || B ) && !(B || C))
  11.         cout<< "("<< A <<" or " <<B <<") and !("<< B << " or "<<C<<") combination is true"<< endl;
  12.     if( (A || (B && C) ) && (!A && !B))
  13.         cout<< "("<< A <<" or (" <<B <<" and "<< C <<")) and (!"<< A << " and !"<<B<<") combination is true" <<endl;
  14.     if( ((B && C ) || (C && A)) && (!(A || B) && C))
  15.         cout << "(( "<<B <<" and "<<C<<") or ("<<C<<" and "<<A <<")) and (!("<<A <<" or "<<B<<") and "<<C<<") combination is true" <<endl;
  16. }
  17.  
  18. int main() {   
  19.     combination(true, true, true);
  20.     combination(true, true, false);
  21.     combination(true, false, false);
  22.     combination(true, false, true);
  23.     combination(false, true, true);
  24.     combination(false, true, false);
  25.     combination(false, false, false);
  26.     combination(false, false, true);
  27.     return 0;
  28. }
Add Comment
Please, Sign In to add comment