JAVA/JAVA Algorithm, Datastruct

[Algorithm] JAVA 코드업 기초 100제 (기초-논리연산) 1053 ~ 1058

큐범 2022. 9. 1. 19:56

1053 : [기초-논리연산] 참 거짓 바꾸기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int i = sc.nextInt();
		
		if(i == 1) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}		
	}

1054 : [기초-논리연산] 둘 다 참일 경우만 참 출력하기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		if(1==Integer.parseInt(s.substring(s.indexOf(" ")+1)) && 1==Integer.parseInt(s.substring(s.indexOf(0)+1, s.indexOf(" ")))) {
			System.out.println("1");
		}else {
			System.out.println("0");
		}
	}

1055 : [기초-논리연산] 하나라도 참이면 참 출력하기(설명)

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		if(1==Integer.parseInt(s.substring(s.indexOf(" ")+1)) || 1==Integer.parseInt(s.substring(s.indexOf(0)+1, s.indexOf(" ")))) {
			System.out.println("1");
		}else {
			System.out.println("0");
		}
	}

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

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		int i1 = Integer.parseInt(s.substring(s.indexOf(" ")+1));
		int i2 = Integer.parseInt(s.substring(s.indexOf(0)+1, s.indexOf(" ")));
				
		if(i1 != i2) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
	}

1057 : [기초-논리연산] 참/거짓이 서로 같을 때에만 참 출력하기

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		int i1 = Integer.parseInt(s.substring(s.indexOf(" ")+1));
		int i2 = Integer.parseInt(s.substring(s.indexOf(0)+1, s.indexOf(" ")));
				
		if(i1 == i2) {
			System.out.println(1);
		}else {
			System.out.println(0);
		}
	}

1058 : [기초-논리연산] 둘 다 거짓일 경우만 참 출력하기

public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		int i1 = Integer.parseInt(s.substring(s.indexOf(" ")+1));
		int i2 = Integer.parseInt(s.substring(s.indexOf(0)+1, s.indexOf(" ")));
				
		if(i1==0 && i2==0) {
			System.out.println(0);
		}else {
			System.out.println(1);
		}
	}