返回列表 發帖
  1. #include <iostream>

  2. using namespace std;

  3. int main()
  4. {
  5.     int a,b,c;
  6.     //cout<<"Please input a b and 1/0 :";
  7.     cin>>a>>b>>c;
  8.     bool impossible=true;
  9.     if(a)
  10.         a=1;
  11.     if(b)
  12.         b=1;
  13.     if((a&b) == c){
  14.         cout<<"AND"<<endl;
  15.         impossible=false;
  16.     }
  17.     if((a|b) == c){
  18.         cout<<"OR"<<endl;
  19.         impossible=false;
  20.     }
  21.     if((a^b) == c){
  22.         cout<<"XOR"<<endl;
  23.         impossible=false;
  24.     }
  25.     if(impossible)
  26.         cout<<"IMPOSSIBLE"<<endl;
  27.     return 0;
  28. }
複製代碼

TOP

返回列表