본문 바로가기
Coding Test/CodeUp

CodeUp_Java 기초 100제 - [기초-논리연산] 둘 다 참일 경우만 참 출력하기 54(설명)

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 == 1){
        	//a와 b 둘다 1인 경우 
        	System.out.println(1);
        } else{
        	//a와 b가 모두 1이 아닌 경우 
        	System.out.println(0);
        }
    }
}
728x90
반응형

댓글