SWEA

[SWEA] 연월일 달력

itsnot4me 2024. 9. 13. 19:14
import java.util.Scanner;
import java.io.FileInputStream;

class Solution
{
	public static void main(String args[]) throws Exception
	{
		Scanner sc = new Scanner(System.in);
		int T;
		T=sc.nextInt();
		int[] days = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
		for(int i = 0; i<T; i++){
            String s=sc.next();
        String year=s.substring(0,4);
        String month=s.substring(4,6);
        String day=s.substring(6,8);
         if(Integer.parseInt(month)>=1 && Integer.parseInt(month)<=12 && Integer.parseInt(day)>=0 && Integer.parseInt(day)<=days[Integer.parseInt(month)-1])
             System.out.println("#"+(i+1)+" "+year+"/"+month+"/"+day);
            else {
                System.out.println("#"+(i+1)+" -1");
		}
	
}
    }

 

'SWEA' 카테고리의 다른 글

[SWEA] 신문 헤드라인  (0) 2024.09.13
[SWEA] 알파벳을 숫자로 변환  (0) 2024.09.13
[SWEA] 자릿수 더하기  (0) 2024.09.13
[SWEA] 중간 값 구하기  (0) 2024.09.12
[SWEA] 최대수 구하기  (0) 2024.09.12