1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.util.Scanner;
 
@SuppressWarnings("resource")
public class Main {
    enum YOIL {
        MON, TUE, WED, THU, FRI, SAT, SUN
    }
    
    public static void main(String args[]) {
        
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        
        
        if ( ( 1 <= x && x <= 12 ) && ( 1 <= y && y <= 31 ) ) {
            
            int currX = 1;
            int currY = 1;
            int currYoil = 0;
            
            // 날짜 계
            while(!(x == currX && y == currY)) {
                switch (currX) {
                case 1:
                case 3:
                case 5:
                case 7:
                case 8:
                case 10:
                case 12:
                    if ( currY == 31 ) {
                        currY = 1;
                        currX++;
                    } else {
                        currY++;
                    }
                    break;
                case 4:
                case 6:
                case 9:
                case 11:
                    if ( currY == 30 ) {
                        currY = 1;
                        currX++;
                    } else {
                        currY++;
                    }
                    break;
                case 2:
                    if ( currY == 28 ) {
                        currY = 1;
                        currX++;
                    } else {
                        currY++;
                    }
                    break;
                default:
                    break;
                }
                
                currYoil++;
            }
            
            System.out.println(printYoil(currYoil));
        }
    }
    
    // 요일 출력
    public static String printYoil(int count) {
        int mid = count;
        if (mid > 6) {
            mid = count % 7;
        }
        
        return YOIL.values()[ mid ].toString();
    }
}
cs


'JAVA > 알고리즘' 카테고리의 다른 글

정렬알고리즘 - 선택정렬  (0) 2018.05.28
10진수 2진수 변환  (0) 2018.05.28
더블링크드 리스트 구현하기  (0) 2018.05.28
백준 1924 - 요일 맞추기  (0) 2018.05.28
백준 2839 - 설탕 배달  (0) 2018.05.28
선택정렬, 버블정렬, 삽입정렬 예제  (0) 2016.12.22

+ Recent posts