public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入年:");
System.out.println("请输入月:");
int year=sc.nextInt();
int month=sc.nextInt();
switch(month) {
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
month=31;
break;
case 2:
if(year%4==0||year%100!=0&&year%400==0)
month=29;
else {
month=28;
}
break;
case 4:
case 6:
case 9:
case 11:
month=30;
break;
}
System.out.println(month);
}
输入年、月、日,显示这个月的天数
最新推荐文章于 2024-10-01 18:51:18 发布