调试了我3个小时内向
Java 代码
import java.util.Scanner;
public class Main{
static int[][] b = new int[3][3];
static int c = 0;
public static void main(String[] args){
Scanner in = new Scanner(System.in);
String[] s = in.nextLine().split("/");
w(Integer.parseInt(s[0]),Integer.parseInt(s[1]),Integer.parseInt(s[2]));
w(Integer.parseInt(s[2]),Integer.parseInt(s[0]),Integer.parseInt(s[1]));
w(Integer.parseInt(s[2]),Integer.parseInt(s[1]),Integer.parseInt(s[0]));
if(c == 3){
int n = b[0][0] * 100 + b[0][1] * 100 + b[0][2];
int m = b[1][0] * 100 + b[1][1] * 100 + b[1][2];
int l = b[2][0] * 100 + b[2][1] * 100 + b[2][2];
if(n == m || m == l || l == n) c--;
else {
if (n < m) {
if (n < l) {
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
if (l < m) {
System.out.printf("%d-%02d-%02d\n", b[2][0], b[2][1], b[2][2]);
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
} else {
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
System.out.printf("%d-%02d-%02d\n", b[2][0], b[2][1], b[2][2]);
}
} else {
System.out.printf("%d-%02d-%02d\n", b[2][0], b[2][1], b[2][2]);
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
}
} else {
if (m < l) {
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
if (n < l) {
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
System.out.printf("%d-%02d-%02d\n", b[2][0], b[2][1], b[2][2]);
} else {
System.out.printf("%d-%02d-%02d\n", b[2][0], b[2][1], b[2][2]);
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
}
} else {
System.out.printf("%d-%02d-%02d\n", b[2][0], b[2][1], b[2][2]);
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
}
}
}
}
if(c == 2){
int n = b[0][0] * 100 + b[0][1] * 100 + b[0][2];
int m = b[1][0] * 100 + b[1][1] * 100 + b[1][2];
if(n == m) c--;
else {
if (n < m) {
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
} else {
System.out.printf("%d-%02d-%02d\n", b[1][0], b[1][1], b[1][2]);
System.out.printf("%d-%02d-%02d\n", b[0][0], b[0][1], b[0][2]);
}
}
}
if(c == 1) System.out.printf("%d-%02d-%02d\n",b[0][0],b[0][1],b[0][2]);
in.close();
}
public static void w(int n,int m,int z) {
if(m <= 0 || m > 12) return;//判断月份是否合理
int[] a = new int[]{0,31,28,31,30,31,30,31,31,30,31,30,31};
if(n >= 60) n += 1900;
else n += 2000;
if(n % 4 == 0 && n % 100 != 0 || n % 400 == 0) a[2]++;//判断是否为闰年
if (a[m] < z || z <= 0) return;//判断日期是否合理
b[c][0] = n;
b[c][1] = m;
b[c++][2] = z;//储存起来,然后判断一下那个日期比较大
}
}