这两个代码我输入14的时候输出不一样,为什么两个都ac了??
查看原帖
这两个代码我输入14的时候输出不一样,为什么两个都ac了??
1030865
letusgo楼主2023/7/9 19:09
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	int a,b,c,d;
	cin >> x;
	if(x%2 == 0 && x>4 && x <= 12){
		a = 1;
	}else{
		a = 0;
	}
	if(x%2 == 0 || x > 4 && x<= 12){
		b = 1;
	}else{
		b = 0;
	}
	if(x%2 == 0 ^ x > 4 && x <= 12){
		c = 1;
	}else{
		c = 0;
	}
	if(x%2 == 0 || x > 4 && x <= 12){
		d = 0;
	}else{
		d = 1;
	}
	cout << a << " " << b << " " << c << " " << d;
	return 0;
} 
#include<bits/stdc++.h>
using namespace std;
int main(){
	int x;
	int a,b,c,d;
	cin >> x;
	if(x%2 == 0 && x>4 && x <= 12){
		a = 1;
	}else{
		a = 0;
	}
	if(x%2 == 0 || x > 4 && x<= 12){
		b = 1;
	}else{
		b = 0;
	}
	if(x%2 == 0 ^ (x > 4 && x <= 12)){
		c = 1;
	}else{
		c = 0;
	}
	if(x%2 == 0 || x > 4 && x <= 12){
		d = 0;
	}else{
		d = 1;
	}
	cout << a << " " << b << " " << c << " " << d;
	return 0;
} 
2023/7/9 19:09
加载中...