본문 바로가기
Coding Test/CodeUp

CodeUp_Java 기초 100제 - [기초-논리연산] 하나라도 참이면 참 출력하기 55(설명)

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개 입력 : ");
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();
        
        if(a == 1 || b == 1){
        	//a와 b 중 하나라도 1인 경우 
        	System.out.println(1);
        } else{
        	//a와 b가 둘 다 0인 경우 
        	System.out.println(0);
        }
    }
}

 

728x90
반응형

댓글