본문 바로가기
Coding Test/CodeUp

CodeUp_Java 기초 100제 - [기초-논리연산] 참/거짓이 서로 다를 때에만 참 출력하기 56(설명)

by SeleniumBindingProtein 2022. 2. 8.
728x90
반응형

//자바코드
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
    	Scanner sc = new Scanner(System.in);
		System.out.print("정수 2개 입력(0, 1) : ");
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        
        if((a == 1 && b == 0) || (a == 0 && b == 1)){
        	//a와 b의 값이 다른 경우 
        	System.out.println(1);
        } else{
        	//a와 b의 값이 다른 경우 
        	System.out.println(0);
        }
    }
}
728x90
반응형

댓글