본문 바로가기
휴지통/알고리즘 & 자료구조

2016년

by 신재권 2022. 11. 1.
package programmers;

public class TwoThousandSixteen년 {

   private static int[] dayOfMonth = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
   private static String[] day = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

   public static void main(String[] args) {
      System.out.println(solution(5, 24));
   }

   public static String solution(int a, int b) {
      int currentDay = 5;
      for (int i = 1; i <= a; i++) {
         for (int j = 1; j <= 31; j++) {
            if (i == a && j == b) {
               break;
            }
            if (isCheck(i, j)) {
               currentDay++;
               if (currentDay == 7) {
                  currentDay = 0;
               }
            }

         }
      }

      return day[currentDay];
   }

   private static boolean isCheck(int month, int day) {
      return dayOfMonth[month] >= day;
   }
}

'휴지통 > 알고리즘 & 자료구조' 카테고리의 다른 글

모의고사  (0) 2022.11.01
폰켓몬  (0) 2022.11.01
삼총사  (0) 2022.10.30
두 개 뽑아서 더하기  (0) 2022.10.30
K번째수  (0) 2022.10.29