본문 바로가기

전체 글79

[백준] 6603번 로또 (자바) 접근 방법 처음에는 그냥 재귀로 탐색하여 풀었으나 순서만 다른 같은 로또 번호 배열이 출력되었습니다. 따라서, 조합이라는 방법을 생각했습니다 조합 : n개의 원소 중에서 r개를 순서 없이 뽑는 경우의 수를 의미합니다. package com.algorithm.boj.recursive; import java.util.Scanner; /* * 문제 : 백준 6603번 로또 * 접근 유형 : 재귀, 조합 * 1. 로또 번호의 순서와 상관없이 선택해야하므로->조합 * */ public class Main_6603 { static int k; static boolean[] check; static int[] lotto; static int[] temp = new int[6]; public static void ma.. 2022. 8. 9.
[백준 BOJ] 1158 요세푸스 문제(자바) 접근 유형 : 큐 접근 방식 N = 7, K = 3 인 경우 1 2 3 4 5 6 7 4 5 6 7 1 2 7 1 2 4 5 4 5 7 1 1 4 5 1 4 public class Main_1158 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt();//사람 수 int K = sc.nextInt(); Queue queue = new LinkedList(); //1~N번까지의 사람들을 넣음 for(int i = 1; i 2022. 8. 9.
이클립스 log cannot be resolved 에러 에러 해결 방법은 다음과 같습니다. 1. pom.xml 파일에서 을 주석 처리하기 2. Maven Dependencies->lombok.jar파일 찾기->마우스 우클릭 후 Run as Java Application 클릭 -> specify location은 eclipse.ini 있는 경로를 선택 3. eclipse.ini 파일 열어보기 -javaagent:lombok.jar (이렇게 되어있는지 확인) -javaagent:본인경로:lombok.jar => 이렇게 되어있으면 경로 지우기 2022. 8. 6.
Comparable 인터페이스, Comparator 인터페이스 1. Comparable 인터페이스 Comparable 인터페이스를 통해 객체를 비교할 수 있다. Comparable 인터페이스의 추상메서드인 compareTo 메서드를 구현해야한다. 2. Comparator 인터페이스 추상메서드인 compare메서드를 구현해야한다. 두 객체를 파라미터로 받아 비교한다. public class CompareTest { public static void main(String[] args) { Student[] students = { new Student("peter", 21), new Student("alley", 25), new Student("cally", 35), new Student("benzino", 55)}; System.out.println("---------.. 2022. 8. 5.