코딩테스트 예제 (24) 썸네일형 리스트형 프로그래머스 배열자르기 예제 import java.util.Arrays; class Solution { public int[] solution(int[] numbers, int num1, int num2) { // numbers 배열의 길이를 갖는 새로운 int형 배열 answer 생성 int[] answer = new int[numbers.length]; // Arrays.copyOfRange() 메소드를 이용하여 // numbers 배열에서 num1부터 num2까지의 요소를 answer 배열에 복사 answer = Arrays.copyOfRange(numbers, num1, num2 + 1); // 결과인 answer 배열 반환 return answer; } } 프로그래머 짝수의 합 class Solution { public int solution(int n) { int answer = 0; for(int i = 1; i 프로그래머스 양꼬치 class Solution { public int solution(int n, int k) { int answer = 0; answer=(n*12000)+((k-(n/10))*2000); return answer; } } 프로그래머스 짝수 홀수 갯수 예제 class Solution { public int[] solution(int[] num_list) { int A = 0; int B = 0; for(int num : num_list){ if(num % 2 == 0){ A++; }else{ B++; } } int[] answer = {A,B}; return answer; } } 프로그래머스 직각삼각형 예제 import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i = 1; i 프로그레머스 문자열 뒤집기 예제 class Solution { public String solution(String my_string) { String answer = ""; for(int i = my_string.length()-1; i>=0; i--){ //거꾸로 길이5 -1 01234 배열같은느낌... 0까지 1씩 빼버리기 answer += my_string.substring(i, i+1); } return answer; } } 프로그래머스 배열뒤집기 예제 class Solution { public int[] solution(int[] num_list) { int[] answer = new int[num_list.length]; for(int i = 0; i 프로그래머스 나이 출력 예제 class Solution { public int solution(int age) { int currentYear = 2022; int birth = 2022-age+1; int answer = birth; return answer; } } 이전 1 2 3 다음