#40338: c++解題攻略


ianlin766909@gmail.com (ian lin)

學校 : 不指定學校
編號 : 245102
來源 : [1.163.104.115]
最後登入時間 :
2024-07-28 16:43:13
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [1.163.70.171] | 發表日期 : 2024-05-11 20:05

#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