#27537: CPP


qgd20040229@gmail.com (时年)

學校 : 不指定學校
編號 : 170559
來源 : [27.105.55.178]
最後登入時間 :
2021-10-10 23:00:28
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [27.105.55.178] | 發表日期 : 2021-10-10 23:46

#include <iostream>

using namespace std;

 

int main(){

  int a, b, c;

  while (cin >> a >> b >> c){

    if (a!=0) a=1;

    if (b!=0) b=1;

    bool found=false;

    if ((a&b)==c){

      found=true;

      cout <<"AND\n";

    }

    if ((a|b)==c){

      found=true;

      cout <<"OR\n";

    }

    if ((a^b)==c){

      found=true;

      cout <<"XOR\n";

    }

    if (!found)

    cout <<"IMPOSSIBLE\n";

  }

  return 0;

}

 
ZeroJudge Forum