CodeUp 1057 - Java알고리즘/CodeUp2023. 8. 8. 22:21
Table of Contents
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] input = sc.nextLine().split(" ");
boolean a = Integer.parseInt(input[0]) != 0;
boolean b = Integer.parseInt(input[1]) != 0;
System.out.println(a^b? 0 : 1);
}
}
a^b는 a,b의 값이 다를 때 즉, 0 1, 1 0이 들어왔을때 true이므로 조건연산식을 0 : 1로 설정
a:1 ^ b:1 = false이므로 1출력
728x90
'알고리즘 > CodeUp' 카테고리의 다른 글
3개의 숫자를 입력받아 가장 작은 값을 반환 (0) | 2023.08.09 |
---|
@leegeonwoo :: geonwoo
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!