https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5QLkdKAz4DFAUq
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
import java.util.Arrays;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int[] days= {31,28,31,30,31,30,31,31,30,31,30,31};
int t=sc.nextInt();
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");
}
}
}
}
'알고리즘 > 삼성 SW expert Academy' 카테고리의 다른 글
[SWEA] 2063. 중간값 찾기_JAVA (0) | 2022.05.04 |
---|---|
[SWEA] 2058. 자릿수 더하기_JAVA (0) | 2022.05.04 |
[SWEA] 2050. 알파벳을 숫자로 변환_JAVA (0) | 2022.05.04 |
[SWEA]1926. 간단한 369게임_JAVA (0) | 2022.05.03 |
[삼성 SW expert Academy] 14178. 1차원 정원_JAVA (0) | 2022.05.03 |