#45879: 再給我兩分鐘,讓我把記憶結成冰


1121226@stu.wghs.tp.edu.tw (Arthur✨EC)

School : 臺北市私立薇閣高級中學
ID : 252772
IP address : [60.248.154.143]
Last Login :
2025-06-20 09:41:12
c461. apcs 邏輯運算子 (Logic Operators) -- apcs | From: [60.248.154.143] | Post Date : 2025-04-23 15:55

#include <bits/stdc++.h>
using namespace std;
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	bool d=false; // 將布林值d預設為false
	if((a&&b)==c){ // 若a and b == c
	    d=true;
	    cout<<"AND"<<endl;
	}
    if((a||b)==c){ // 若a or b == c
        d=true;
        cout<<"OR"<<endl;
    }
    if(a^b==c){ // 若a xor b == c
        d=true;
        cout<<"XOR"<<endl;
    }
    if(d==false){ // 若前三者不符合
        cout<<"IMPOSSIBLE";
    }
}
 
ZeroJudge Forum