题解 | #出生日期输入输出#
出生日期输入输出
https://www.nowcoder.com/practice/4a4a9dd1edb6453ba4a0432319200743
import java.util.Scanner; // 注意类名必须为 Main, 不要有任何 package xxx 信息 public class Main { public static void main(String[] args) { Scanner in = new Scanner(System.in); String s = in.nextLine(); String s1 = s.substring(0,4); String s2 = s.substring(4,6); String s3 = s.substring(6,8); int x = Integer.parseInt(s1); int y = Integer.parseInt(s2); int z = Integer.parseInt(s3); if(x >= 1990 & x <= 2015 & y >= 1 & y <= 12 & z >= 1 & z <= 30){ System.out.println("year="+s1); System.out.println("month="+s2); System.out.println("date="+s3); } } }