본문 바로가기

알고리즘

SW 2047 신문 헤드라인 SW Expert Academy 0. 문제 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 1. 풀이 import java.util.ArrayList; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String N = sc.next(); ArrayList list = new ArrayList(); for (int i = 0; i < N.length(); i++) { list.add(N.charAt(i) - 64); } for (in.. 더보기
SW Academy D1 - 연월일 달력 0. 문제 SW Expert Academy SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 1. 내 풀이 import java.util.ArrayList; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); sc.nextLine(); ArrayList list = new ArrayList(); for (int i = 1; i 12 || month < 1) { System.out.println("#".. 더보기
2058 중간값 더하기 SW Expert Academy SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 1. 내가 푼 방법 사용자의 입력 값이 한 자리 수에서 4자리 수로 다양할 수 있음으로, 각 상황에 맞는 if 분기를 만들어서, 하드코딩 했다. import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); System.out.println(Calc(N)); } static int Calc(int N) { if(9999>=N &&.. 더보기
SW Expert Academy D1 - 2063 중간값 찾기 https://swexpertacademy.com/main/code/problem/problemDetail.do?problemLevel=1&contestProbId=AV5QPsXKA2UDFAUq&categoryId=AV5QPsXKA2UDFAUq&categoryType=CODE&problemTitle=&orderBy=FIRST_REG_DATETIME&selectCodeLang=ALL&select-1=1&pageSize=10&pageIndex=1 SW Expert Academy SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요! swexpertacademy.com 1. Old school 로 풀기 맨 첫 케이스에서 받은 배열의 사이즈를 이용해 배열을 만들고 그 후 나열된 값들을 배열에.. 더보기
예외 처리 _Quiz_11 public class _Quiz_11 { public static void main(String[] args) { int errorCode = 0; try{ if(errorCode ==0) { System.out.println("상품 구매를 완료하였습니다."); } else if(errorCode == 1) { throw new timeOutException("상품 구매 가능 시간이 아닙니다."); } else if (errorCode == 2) { throw new soldOutException("해당 상품은 매진되었습니다."); } }catch (timeOutException e){ System.out.println(e.getMessage()); System.out.println("상품 구매는 20.. 더보기
백준 10818번 최대 최소 스트림을 배우고 모든게 쉬워진 나 orElse 문 안 쓰면 Optional int 란 자료형으로 나옴. 왜냐면 만약 배열이 비어있을 경우에 대한 대처를 안 했기 때문이다. 따라서 orElse(0)를 해줘야 컴파일러가 믿고 int로 변환해준다. import java.util.Scanner; import java.util.stream.IntStream; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] b = new int[N]; for (int i = 0; i < N; i++) { b[i] = sc.nextInt(); } int mi.. 더보기
[JAVA 퀴즈 #10] 나도 코딩 import java.util.ArrayList; import java.util.Arrays; public class _Quiz_10 { public static void main(String[] args) { Customer c1 = new Customer("챈들러", 50); Customer c2 = new Customer("레이첼", 42); Customer c3 = new Customer("모니카", 21); Customer c4 = new Customer("벤자민", 18); Customer c5 = new Customer("제임스", 5); System.out.println("미술관 입장료"); System.out.println("-----------------"); ArrayList list.. 더보기
JAVA Quiz 09 import java.util.ArrayList; public class _Quiz_09 { public static void main(String[] args) { ArrayList stuList = new ArrayList(); stuList.add(new student("유재석", "파이썬")); stuList.add(new student("박명수", "자바")); stuList.add(new student("김종국", "자바")); stuList.add(new student("조세호", "C")); stuList.add(new student("서장훈", "파이썬")); System.out.println("자바 자격증을 보유한 학생"); System.out.println("--------------.. 더보기