標題:
邏輯運算子
[打印本頁]
作者:
李知易
時間:
2025-1-18 13:12
標題:
邏輯運算子
[attach]20484[/attach]
作者:
洪承廷
時間:
2025-1-25 09:09
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d=0;
cin>>a>>b>>c;
if((a and b)==c)
{
d++;
cout<<"AND"<<endl;
}
if((a or b) ==c)
{
cout<<"OR"<<endl;
if((a and b)==0)
cout<<"XOR";
d++;
}
if((a*b!=0 and c==0))
{
cout<<"XOR";
d++;
}
if(d==0)
cout<<"IMPOSSIBLE";
return 0;
}
複製代碼
作者:
高鋐鈞
時間:
2025-1-25 09:38
#include<bits/stdc++.h>
using namespace std;
int main()
{
cin.tie(0);
cin.sync_with_stdio(0);
int a,b,c,x=0,s=0;
cin>>a>>b>>c;
if(c){
if(a&&b){
cout<<"AND"<<endl;
s++;
}
if(a||b){
cout<<"OR"<<endl;
s++;
}
if(!(a==b)){
cout<<"XOR"<<endl;
s++;
}
if(s){
}else{
cout<<"IMPOSSIBLE";
}
}else{
if(!(a&&b)){
cout<<"AND"<<endl;
x++;
}
if(!(a||b)){
cout<<"OR"<<endl;
x++;
}
if(a==b){
cout<<"XOR"<<endl;
x++;
}else if(a!=0&&b!=0){
cout<<"XOR"<<endl;
x++;
}
if(x){
}else{
cout<<"IMPOSSIBLE";
}
}
return 0;
}
複製代碼
作者:
張駿霖
時間:
2025-1-25 09:59
#include<bits/stdc++.h>
using namespace std;
int main()
{
int a, b, c, d=0;
cin>>a>>b>>c;
if((a and b)==c)
{
d++;
cout<<"AND"<<endl;
}
if((a || b) ==c)
{
cout<<"OR"<<endl;
if((a && b)==0)
cout<<"XOR";
d++;
}
if((a*b!=0 && c==0))
{
cout<<"XOR";
d++;
}
if(d==0)
cout<<"IMPOSSIBLE";
return 0;
}
複製代碼
作者:
高昀昊
時間:
2025-2-7 20:57
#include<bits/stdc++.h>
using namespace std;
int main()
{
cin.sync_with_stdio(0);
cout.sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long a,b,c,n=0;
cin>>a>>b>>c;
if((a!=0 && b!=0)==c){
cout<<"AND\n";
n++;
}
if((a!=0 || b!=0) ==c){
cout<<"OR\n";
n++;
}
if((a*b==0 && a+b!=0)==c){
cout<<"XOR\n";
n++;
}
if(n==0){
cout<<"IMPOSSIBLE\n";
}
return 0;
}
複製代碼
歡迎光臨 種子論壇 | 高雄市資訊培育協會學員討論區 (http://istak.org.tw/seed/)
Powered by Discuz! 7.2