1051 : [기초-비교연산] 두 정수 입력받아 비교하기3
import java.util.*;
public class Main {
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(b >= a ? 1 : 0);
}
}
1052 : [기초-비교연산] 두 정수 입력받아 비교하기4
import java.util.*;
public class Main {
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a != b ? 1 : 0);
}
}
1053 : [기초-논리연산] 참 거짓 바꾸기
import java.util.*;
public class Main {
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
System.out.println(a == 0 ? 1 : 0);
}
}
1054 : [기초-논리연산] 둘 다 참일 경우만 참 출력하기
import java.util.*;
public class Main {
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a == 1 && b == 1? 1 : 0);
}
}
새롭게 알게된 점
그냥 각각 == 1 && 해주면 되는 거였다!
1055 : [기초-논리연산] 하나라도 참이면 참 출력하기
import java.util.*;
public class Main {
public static void main(String arg[]) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println(a == 1 || b == 1? 1 : 0);
}
}

'Algorithm > 코드업' 카테고리의 다른 글
| [코드업 기초 100제] Java 1056 ~1060 풀이 (0) | 2025.08.31 |
|---|---|
| [코드업 기초 100제] Java 1046 ~1050 풀이 (1) | 2025.08.30 |
| [코드업 기초 100제] Java 1041 ~1045 풀이 (0) | 2025.08.30 |
| [코드업 기초 100제] Java 1036 ~1040 풀이 (0) | 2025.08.30 |
| [코드업 기초 100제] Java 1031 ~1035 풀이 (1) | 2025.08.19 |