공부하는 히욤이

2056. 연월일 달력 본문

Algorithm/SW Expert Academy

2056. 연월일 달력

히욤이 2019. 1. 17. 22:44

SW Expert 2056. 연월일 달력

문제의 저작권은 SW Expert에 있습니다 


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
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Solution {
 
    static String Answer;
    static int[] dayofMonth = {031,28,31,30,31,30,31,31,30,31,30,31}; 
    static String answer;
 
    public static void main(String[] args) throws Exception {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        //BufferedReader br = new BufferedReader(new FileReader("input.txt"));
 
        int T = Integer.parseInt(br.readLine());
        for(int test_case = 0; test_case < T; test_case++) {
            String s = br.readLine();
            int month = Integer.parseInt(s.substring(46));
            int day = Integer.parseInt(s.substring(68));
            if (month >0 && month <13 && day >0 && day<=dayofMonth[month]) {
                answer = String.format("%s/%s/%s", s.substring(0,4), s.substring(4,6), s.substring(6,8));
 
            }
            else {
                answer = "-1";
            }
 
             System.out.format("#%d %s", (test_case+1), answer);
             System.out.println();
        }
        br.close();
    }
}
cs


'Algorithm > SW Expert Academy' 카테고리의 다른 글

1989. 초심자의 회문 검사  (0) 2019.01.23
1986. 지그재그 숫자  (0) 2019.01.23
2071. 평균값 구하기  (0) 2019.01.11
2063. 중간값 찾기  (0) 2019.01.11
1545. 거꾸로 출력해 보아요  (0) 2019.01.11