본문 바로가기

자바137

[백준/Java] 3003번 킹, 퀸, 룩, 비숍, 나이트, 폰 -코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] chess = {1, 1, 2, 2, 2, 8}; int[] myChess = new int[6]; int n; for (int i = 0; i < chess.length; i++) { myChess[i] = sc.nextInt(); } for (int i = 0; i < chess.length; i++) { n = chess[i] - myChess[i]; System.out.print(n + " "); } } } 2022. 4. 10.
[백준/Java] 2914번 저작권 -코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int i = sc.nextInt(); System.out.println(a * (i - 1) + 1); } } 2022. 4. 10.
[백준/Java] 2845번 파티가 끝나고 난 뒤 -코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); int p = sc.nextInt(); int[] arr = new int[5]; int[] result = new int[5]; for (int i = 0; i < arr.length; i++) { arr[i] = sc.nextInt(); } for (int i = 0; i < arr.length; i++) { result[i] = arr[i] - (l * p); } for(int i : result) { System.out.print(i.. 2022. 4. 10.
[백준/Java] 2558번 A+B - 2 -코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); System.out.println(a + b); } } 2022. 4. 9.
[백준/Java] 2557번 Hello World -코드 public class Main { public static void main(String[] args) { System.out.println("Hello World!"); } } 2022. 4. 9.
[백준/Java] 2475번 검증수 -코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] koiNum = new int[5]; int total = 0; for (int i = 0; i < koiNum.length; i++) { koiNum[i] = sc.nextInt(); } for (int num : koiNum) { total += Math.pow(num, 2); } System.out.println(total % 10); } } 2022. 4. 9.