두 수의 나눗셈
/* 두 수의 나눗셈 * 정수 num1과 num2가 매개변수로 주어질 때, * num1을 num2로 나눈 값에 1,000을 곱한 후 정수 부분을 return * * num1 num2 result * 3 2 1500 num1이 3, num2가 2이므로 3 / 2 = 1.5에 1,000을 곱하면 1500 * 7 3 2333 num1이 7, num2가 3이므로 7 / 3 = 2.33333...에 1,000을 곱하면 2333.3333.... 이 되며, 정수 부분은 2333 * 1 16 62 num1이 1, num2가 16이므로 1 / 16 = 0.0625에 1,000을 곱하면 62.5가 되며, 정수 부분은 62 */ 12345678910111213141516171819202122232425import java...
배열 두배 만들기
/* 배열 두배 만들기 * 정수 배열 numbers가 매개변수로 주어집니다. * numbers의 각 원소에 두배한 원소를 가진 배열을 return * * numbers result * [1, 2, 3, 4, 5] [2, 4, 6, 8, 10] * [1, 2, 100, -99, 1, 2, 3] [2, 4, 200, -198, 2, 4, 6] */ 123456789101112131415161718192021public class programmer_0_36 { static int[] a1 = {1, 2, 3, 4, 5}; static int[] a2 = {1, 2, 100, -99, 1, 2, 3}; public int[] solution(int[] numbers) { int[] answer = new in..
중앙값 구하기
/* 중앙값 구하기 * 1, 2, 7, 10, 11의 중앙값은 7 * 수 배열 array가 매개변수로 주어질 때, 중앙값을 return * * array result * [1, 2, 7, 10, 11] 7 * [9, -1, 0] 0 */ 12345678910111213141516171819202122import java.util.*;public class programmer_0_37 { static int[] a1 = {1, 2, 7, 10, 11}; static int[] a2 = {9, -1, 0}; public int solution(int[] array) { int answer = 0; Arrays.sort(array); answer = array[array.length % 2]; return a..
짝수는 싫어요
/* 짝수는 싫어요 * 정수 n이 매개변수로 주어질 때, * n 이하의 홀수가 오름차순으로 담긴 배열을 return * * n result * 10 [1, 3, 5, 7, 9] * 15 [1, 3, 5, 7, 9, 11, 13, 15] */ 123456789101112131415161718192021222324import java.util.*;public class programmer_0_38 { static int a1 = 10; static int a2 = 15; public List solution(int n) { List answer = new ArrayList(); for(int i = 1; i 0){ answer.add(i); } } return answer; } public static vo..