전체 글
-
intellij 자동 포맷팅 시 줄 바꿈 처리 적용해주기프로젝트/게시판 프로젝트 2022. 5. 19. 10:08
자동 포맷팅이란? 코드를 정해진 방식대로 자동으로 정렬을 시켜주어 가독성을 높여주는 기능입니다. intellij에서 자동 포맷팅을 적용하는 단축키는 Ctrl + Alt + L입니다. 문제가 발생한 점 빌더 패턴을 사용하게 되면 코드가 길어지는 경우가 있어 자동 포맷팅을 적용을 하였습니다. 하지만 줄 바꿈은 동작하지 않았습니다. 기존의 코드 만약 다음과 같이 된다면 가독성이 훨씬 올라가겠죠? 해결 방법 1. File -> Settings로 이동합니다. ( 단축키 : Ctrl + Alt + S) 2. Code Style으로 검색하여 Java를 클릭합니다. 3. 중간 상단에 있는 Wrapping and Braces를 선택합니다. 4. Chained method calls에서 설정을 변경합니다. Wrap alw..
-
[백준] 5373번 : 큐빙 - 자바(JAVA)알고리즘/백준 2022. 5. 19. 00:01
https://www.acmicpc.net/problem/5373 5373번: 큐빙 각 테스트 케이스에 대해서 큐브를 모두 돌린 후의 윗 면의 색상을 출력한다. 첫 번째 줄에는 뒷 면과 접하는 칸의 색을 출력하고, 두 번째, 세 번째 줄은 순서대로 출력하면 된다. 흰색은 w, 노란 www.acmicpc.net 문제 해석 큐브는 3 x 3 x 3개의 작은 정육면체로 이루어져 있습니다. 퍼즐을 풀려면 각 면에 있는 아홉 개의 작은 정육면체의 색이 동일해야 합니다. 큐브는 각 면을 양방향으로 90도 만큼 돌릴 수 있도록 만들어져 있습니다. 이 문제에서는 큐브가 모두 풀린 상태에서 시작합니다. 윗면은 흰색, 아랫면은 노란색, 앞면은 빨간색, 뒷면은 오렌지색, 왼쪽면은 초록색, 오른쪽 면을 파란색입니다. 큐브를 ..
-
로그인 기능을 만들어보자프로젝트/게시판 프로젝트 2022. 5. 18. 01:23
로그인 기능을 만들기 위해 궁금한 점을 하나씩 해결해보겠습니다. 1. 로그인 방식은 POST일까 GET일까? 로그인은 사용자의 정보를 조회하는 것이니까 GET을 써야 하지 않을까?라고 생각했습니다. 하지만 GET 방식의 경우 입력받은 정보들을 URL 쿼리문으로 보내며 POST 방식은 body로 감싸서 보냅니다. 즉, GET의 경우에는 그대로 노출되고 POST의 경우에는 보안성이 증가됩니다. 로그인의 경우에는 민감한 정보로 보안이 필요하기 때문에 POST를 사용합니다. 하지만 만약 SSL을 사용한다면 GET/ POST둘다 암호화되기 때문에 GET을 사용하면 될 것 같다고 생각했습니다. 하지만 로그인하는 과정을 통해서 토큰 / 세션이 생성된다면 이는 POST가 또 맞다고 볼 수 있습니다. 또한 사용자가 UR..
-
[백준] 2357번 : 최솟값과 최댓값 - 자바(JAVA)알고리즘/백준 2022. 5. 18. 00:01
https://www.acmicpc.net/problem/2357 2357번: 최솟값과 최댓값 N(1 ≤ N ≤ 100,000)개의 정수들이 있을 때, a번째 정수부터 b번째 정수까지 중에서 제일 작은 정수, 또는 제일 큰 정수를 찾는 것은 어려운 일이 아니다. 하지만 이와 같은 a, b의 쌍이 M(1 ≤ M ≤ 100 www.acmicpc.net 문제 해석 N개의 정수들이 존재합니다. (1 ~ 100,000) a번째 정수부터 b번째 정수까지 중에서 제일 작은 정수, 또는 제일 큰 정수를 찾는 것은 어려운 일이 아닙니다. 하지만 이와 같은 a, b의 쌍이 M개 주어졌을 때는 어려운 문제가 됩니다. (1~ 100,000) 여기서 a번째라는 것은 입력되는 순서로 a번째라는 이야기입니다. 예를 들어 a=1, ..
-
TCP연결이 갑자기 끊기면 어떻게 될까? = 유령 세션CS/네트워크 2022. 5. 17. 22:40
TCP와 네트워크에 대해 잘 모르신다면 다음 글을 읽고 오시면 좋습니다. https://junuuu.tistory.com/259 OSI 7계층이란? OSI 7 계층이란?(What) Open System Interconnection의 약자로 간단하게 "서로 다른 제조사 시스템 간의 호환성 해결"을 위해 ISO 국제표준 국가에 의해 재정되었습니다. 네트워크에서 통신이 일어나는 과정 junuuu.tistory.com 유령 세션이란? 서버에 연결된 클라이언트 세션이 제대로 연결해제 되지 않고 남아 있는 상태를 유령 세션이라고 합니다. 접속 해제에 대한 감지가 이루어지지 않았기 때문에 할당된 리소스 등이 해제되지 않고, 재접속 시 문제를 일으킬 수 있습니다. 유령 세션이 발생하는 이유 일반적인 TCP 흐름은 다음..
-
[백준] 1149번 : RGB거리 - 자바(JAVA)알고리즘/백준 2022. 5. 17. 00:01
https://www.acmicpc.net/problem/1149 1149번: RGB거리 첫째 줄에 집의 수 N(2 ≤ N ≤ 1,000)이 주어진다. 둘째 줄부터 N개의 줄에는 각 집을 빨강, 초록, 파랑으로 칠하는 비용이 1번 집부터 한 줄에 하나씩 주어진다. 집을 칠하는 비용은 1,000보다 작거나 www.acmicpc.net 문제 해석 RGB거리에는 집이 N개가 존재한다. 거리는 선분으로 나타낼 수 있고 1번 집부터 N번 집이 순서대로 있다. 집은 빨강, 초록, 파랑 중 하나의 색으로 칠해야 한다. 각각의 집을 빨강,초록,파랑으로 칠하는 비용이 주어졌을 때, 아래 규칙을 만족하면서 모든 집을 칠하는 비용의 최솟값을 구해보자. 1번 집의 색은 2번집의 색과 같지 않아야 한다. N번 집의 색은 N-1..
-
[백준] 4485번 - 녹색 옷 입은 애가 젤다지? - 자바(JAVA)알고리즘/백준 2022. 5. 16. 00:01
https://www.acmicpc.net/problem/4485 4485번: 녹색 옷 입은 애가 젤다지? 젤다의 전설 게임에서 화폐의 단위는 루피(rupee)다. 그런데 간혹 '도둑루피'라 불리는 검정색 루피도 존재하는데, 이걸 획득하면 오히려 소지한 루피가 감소하게 된다! 젤다의 전설 시리즈의 주 www.acmicpc.net 문제 해석 젤다의 전설 게임의 화폐 단위는 루피이다. '도둑 루피'라 불리는 검은색 루피도 존재하여 이것을 획득하면 오히려 소지한 루피가 감소됩니다. 현재 주인공 '링크'는 도둑루피만 가득한 N x N 크기의 동굴의 제일 왼쪽 위에 있습니다. 즉, 시작점은 (0,0)에 위치 링크는 이 동굴의 반대편 출구, 제일 오른쪽 아래 칸인 [N-1][N-1]까지 이동해야 합니다. 이동은 상..
-
3124. 최소 스패닝 트리 - 자바(JAVA)알고리즘/SW Expert Academy 2022. 5. 16. 00:01
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV_mSnmKUckDFAWb SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 문제 해석 그래프가 주어졌을 때, 그 그래프의 최소 스패닝 트리를 구하는 프로그램을 작성하세요. 최소 스패닝 트리는, 주어진 그래프의 모든 정점들을 연결하는 부분 그래프 중에서 그 가중치의 합이 최소인 트리를 말합니다. 입력으로 주어지는 그래프는 하나의 연결 그래프임이 보장됩니다. 문제 풀이 전 설계 스패닝 트리를 계산하는 알고리즘으로는 프림 알고리즘과 크루스 칼 알고리즘이 존재합니다. 본 문제에서..