题目描述:
CCC老师的生日是YY年MM月DD日,他想知道自己出生后第一万天纪念日的日期(出生日算第0天)。
代码:
- package lanqiao;
-
- import java.time.LocalDate;
- import java.util.*;
-
- public class Main {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- while(sc.hasNext())
- {
- int y = sc.nextInt();
- int m = sc.nextInt();
- int d = sc.nextInt();
- LocalDate begin = LocalDate.of(y,m,d);
- LocalDate end = LocalDate.of(y + 40,m,d);
- int days = 0;
- while(!begin.isAfter(end))
- {
- begin = begin.plusDays(1);
- days += 1;
- if(days == 10000)
- {
- String[] s = begin.toString().split("-");
- System.out.printf("%s-%d-%d\n",s[0],Integer.parseInt(s[1]),Integer.parseInt(s[2]));
- }
- }
- }
- }
- }