T542779 逻辑运算不会
  • 板块灌水区
  • 楼主W_w_C_c_X_x
  • 当前回复5
  • 已保存回复5
  • 发布时间2024/11/23 16:43
  • 上次更新2024/11/23 19:16:30
查看原帖
T542779 逻辑运算不会
1380433
W_w_C_c_X_x楼主2024/11/23 16:43

T542779 逻辑运算

#include<bits/stdc++.h>
using namespace std;
int n,m,a[1005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	for(int i=1;i<=m;++i){
		int opt,x,y;
		cin>>opt;
		if(opt==1){
			cin>>x>>y;
			if(a[x]==1&&a[y]==1)
				cout<<"1 "<<endl;
			else
				cout<<"0 "<<endl;
		}
		else if(opt==2){
			cin>>x>>y;
			if(a[x]==1||a[y]==1)
				cout<<"1 "<<endl;
			else
				cout<<"0 "<<endl;
		}
		else{
			cin>>x;
			if(!(a[x]==1))
				cout<<"1 "<<endl;
			else
				cout<<"0 "<<endl;
		}
	}
	return 0;
}

各位,能帮我查一下错吗?

2024/11/23 16:43
加载中...