参考代码:
import java.util.Scanner; import java.util.Set; import java.util.TreeSet; import java.time.LocalDate; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String in = scanner.next(); String []s = in.split("/"); int a = Integer.parseInt(s[0]); int b = Integer.parseInt(s[1]); int c = Integer.parseInt(s[2]); Set<LocalDate> set = new TreeSet<>(); try { LocalDate date1 = LocalDate.of(year(a), b, c); set.add(date1); }catch(Exception e) {} try { LocalDate date2 = LocalDate.of(year(c), a, b); set.add(date2); }catch(Exception e) {} try { LocalDate date3 = LocalDate.of(year(c), b, a); set.add(date3); }catch(Exception e) {} for(LocalDate x: set) System.out.println(x); } public static int year(int a) { return (a > 60) ? (a + 1900) : (a + 2000); } }
0.0分
6 人评分
C二级辅导-等差数列 (C语言代码)浏览:1315 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:689 |
汽水瓶 (C语言代码)浏览:764 |
C语言训练-排序问题<1> (C++代码)浏览:632 |
【明明的随机数】 (C++代码)浏览:834 |
C语言程序设计教程(第三版)课后习题1.6 (C++代码)浏览:909 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:467 |
【简单计算】 (C语言代码)浏览:642 |
C语言程序设计教程(第三版)课后习题6.6 (C语言代码)浏览:366 |
字符逆序 (C语言代码)浏览:706 |