자바137 [백준/Java] 4299번 최댓값 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] nums = new int[9]; int max = 0; int index = 0; for (int i = 0; i max){ max = nums[i]; index = i + 1; } } System.out.println(max); System.out.println(index); } } 2022. 4. 16. [백준/Java] 5532번 방학 숙제 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int l = sc.nextInt(); double b = sc.nextDouble(); double a = sc.nextDouble(); double c = sc.nextDouble(); double d = sc.nextDouble(); double result = l - Math.max(Math.ceil(b / c), Math.ceil(a / d)); System.out.println((int) result); } } 2022. 4. 16. [백준/Java] 4299번 AFC 윔블던 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int scoreSum = sc.nextInt(); int scoreMinus = sc.nextInt(); int team1 = scoreSum + scoreMinus; int team2 = scoreSum - scoreMinus; if (team1 % 2 != 0 && team2 % 2 != 0) { System.out.println(-1); } else { if (team1 / 2 >= 0 && team2 / 2 >= 0) { System.out.println(team1 .. 2022. 4. 16. [백준/Java] 2438번 체스판 조각 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); System.out.println((n / 2 + 1) * (n - n / 2 + 1)); } } 2022. 4. 16. [백준/Java] 2752번 세수정렬 -Code import java.util.Arrays; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] nums = new int[3]; for (int i = 0; i < 3; i++) { nums[i] = sc.nextInt(); } Arrays.sort(nums); for (int num : nums){ System.out.print(num + " "); } } } 2022. 4. 16. [백준/Java] 2588번 곱셈 -Code import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num = sc.nextInt(); String num2 = sc.next(); for (int i = 0; i < 3; i++) { System.out.println(num * (num2.charAt(2 - i) - '0')); } System.out.println(num * Integer.parseInt(num2)); } } 처음 문자열을 배열 형태로 받으려다 잘 안되서 찾아보니 charAt이 있어서 사용했고 (int)로 캐스팅을 하니 이상한 값이나와서 전에 사용했.. 2022. 4. 16. 이전 1 ··· 6 7 8 9 10 11 12 ··· 23 다음