1046 : [기초-산술연산] 정수 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();
int c = sc.nextInt();
System.out.println(a + b + c);
System.out.printf("%.1f", (float)(a + b + c)/3);
}
}
1047 : [기초-비트시프트연산] 정수 1개 입력받아 2배 곱해 출력하기
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 << 1);
}
}
1048 : [기초-비트시프트연산] 한 번에 2의 거듭제곱 배로 출력하기
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);
}
}
1049 : [기초-비교연산] 두 정수 입력받아 비교하기1
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);
}
}
1050 : [기초-비교연산] 두 정수 입력받아 비교하기2
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);
}
}
새롭게 알게된 점
Scanner sc = new Scanner(System.in);
// System.in은 입력받은 값을 바이트 단위로 받아들이겠다는 의미

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