参考代码:
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 人评分
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:568 |
蓝桥杯历届试题-九宫重排 (C++代码)浏览:2812 |
C语言训练-求PI* (C语言代码)浏览:639 |
C语言程序设计教程(第三版)课后习题11.8 (C语言代码)浏览:910 |
C语言程序设计教程(第三版)课后习题9.4 (C语言代码)浏览:699 |
有关字符,字符串的输入输出函数说明浏览:498 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1457 |
单词个数统计 (C语言代码)浏览:1046 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:985 |
神奇的fans (C语言代码)浏览:1125 |