-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSWEA2056.java
More file actions
23 lines (21 loc) · 855 Bytes
/
SWEA2056.java
File metadata and controls
23 lines (21 loc) · 855 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package SWEA;
import java.util.Scanner;
public class SWEA2056 {
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");
}
}
}
}