DSTJZ


私信TA

用户名:dotcpp0721777

访问量:4443

签 名:

天下难事,必作于易;天下大事,必作于细。

等  级
排  名 50
经  验 10992
参赛次数 13
文章发表 312
年  龄 18
在职情况 学生
学  校 狗熊岭23届毕业生
专  业

  自我简介:


参考代码:

import java.util.Scanner;

public class  Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        String in = scanner.next();
        String []num = in.split("/");
        int a = Integer.parseInt(num[0]);
        int b = Integer.parseInt(num[1]);
        int c = Integer.parseInt(num[2]);
        for(int i = 19600101; i <= 20591231; i++)
        {   int year = i / 10000;
            int month = i / 100 % 100;
            int day = i % 100;
            if(check(year, month, day))
            {   int t = year % 100;
                if(t == a && month == b && day == c ||
                    month == a && day == b && t == c ||
                     day == a && month == b && t == c)
                    System.out.printf("%d-%02d-%02d\n", year, month, day);
            }
        }
    }
    public static int []days = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
    public static boolean check(int year, int month, int day)
    {   if(month > 12 || month == 0)
        return false;
        days[2] = (year % 400 == 0 || year % 4 == 0 && year % 100 != 0) ? 29 : 28;
        if(day == 0 || day > days[month])
            return false;
        return true;
    }
}


 

0.0分

6 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区