[Programmers] #181917 - 간단한 논리 연산 [Java][C++][Python]
[Programmers] #181917 - 간단한 논리 연산 [Java][C++][Python]
1. 아이디어
$\lor$는 or, $\land$는 and이므로 $(x_1 \lor x_2) \land (x_3 \lor x_4)$를 괄호까지 그대로 옮기면 된다.
2. 코드
풀이 [Java][C++][Python]
1
2
3
4
5
class Solution {
public boolean solution(boolean x1, boolean x2, boolean x3, boolean x4) {
return (x1 || x2) && (x3 || x4);
}
}
1
2
3
4
5
6
#include <bits/stdc++.h>
using namespace std;
bool solution(bool x1, bool x2, bool x3, bool x4) {
return (x1 || x2) && (x3 || x4);
}
1
2
def solution(x1, x2, x3, x4):
return (x1 or x2) and (x3 or x4)
This post is licensed under CC BY 4.0 by the author.