[C++] 프로그래머스 간단한 논리 연산

문제설명

boolean 변수 x1, x2, x3, x4가 매개변수로 주어질 때,
다음의 식의 true/false를 return 하는
solution 함수를 작성해 주세요.

• (x1 ∨ x2) ∧ (x3 ∨ x4)


입출력 예

x1 x2 x3 x4 result
false true true true true


풀이

논리 연산을 구현하는 간단한 구현 문제였습니다.

#include <string>
#include <vector>

using namespace std;

bool solution(bool x1, bool x2, bool x3, bool x4) {
    bool answer = true;
    
    answer = (x1 || x2) && (x3 || x4);
    
    return answer;
}


결과

코드 실행결과

Categories:

Updated:

Leave a comment