参考代码:
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int a = sc.nextInt(); for (int i = a + 1; i <= 100000000; i++) { int g = i % 10; int s = i / 10 % 10; int b = i / 100 % 10; int q = i / 1000 % 10; int w = i / 10000 % 10; int sw = i / 100000 % 10; int bw = i / 1000000 % 10; int qw = i / 10000000 % 10; int y = i / 100 % 100; int day = i % 100; int n = i / 1000; if (y > 12 || y < 1) { continue; } if (qw == g && bw == s && sw == b && w == q) { if ((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0)) { if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) { if (day > 31 || day < 1) { continue; } } else if (y == 4 || y == 6 || y == 9 || y == 11) { if (day > 30 || day < 1) { continue; } } else if (y == 2) { if (day > 29 || day < 1) { continue; } } } else { if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) { if (day > 31 || day < 1) { continue; } } else if (y == 4 || y == 6 || y == 9 || y == 11) { if (day > 30 || day < 1) { continue; } } else if (y == 2) { if (day > 28 || day < 1) { continue; } } } System.out.println(i); break; } } for (int i = a + 1; i <= 100000000; i++) { int g = i % 10; int s = i / 10 % 10; int b = i / 100 % 10; int q = i / 1000 % 10; int w = i / 10000 % 10; int sw = i / 100000 % 10; int bw = i / 1000000 % 10; int qw = i / 10000000 % 10; int y = i / 100 % 100; int day = i % 100; int n = i / 1000; if (y > 12 || y < 1) { continue; } if (qw == sw && qw == b && qw == g && bw == w && bw == q && bw == s) { if ((n % 4 == 0 && n % 100 != 0) || (n % 400 == 0)) { if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) { if (day > 31 || day < 1) { continue; } } else if (y == 4 || y == 6 || y == 9 || y == 11) { if (day > 30 || day < 1) { continue; } } else if (y == 2) { if (day > 29 || day < 1) { continue; } } } else { if (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12) { if (day > 31 || day < 1) { continue; } } else if (y == 4 || y == 6 || y == 9 || y == 11) { if (day > 30 || day < 1) { continue; } } else if (y == 2) { if (day > 28 || day < 1) { continue; } } } System.out.println(i); break; } } } }
0.0分
6 人评分
2005年春浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:784 |
C语言程序设计教程(第三版)课后习题7.3 (C语言代码)浏览:641 |
C二级辅导-同因查找 (C语言代码)浏览:592 |
简单的a+b (C语言代码)浏览:827 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:793 |
C语言程序设计教程(第三版)课后习题6.3 (C语言代码)浏览:688 |
IP判断 (C语言描述,蓝桥杯)浏览:1118 |
C语言程序设计教程(第三版)课后习题5.5 (C语言代码)浏览:582 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1457 |
众数问题 (C语言代码)浏览:717 |