package cn.tedu.day02;
import java.util.Scanner;
public class Switch04 {
public static void main (String[] args){
Scanner sc=new Scanner(System.in);
int year =sc.nextInt();
int month =sc.nextInt();
int days=31;
switch(month){
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
break;
}
switch(month){
case 4:
case 6:
case 9:
case 11:
days =30;
break;
case 2:{
days=((year%4==0&&year%100!=0)||year%400==0)?29:28;
```
}
break;
}
System.out.println(year+"年"+month+"月有"+days+"天");
sc.close();
}
```
}
根据用户输入的年份和月份判断有多少天
最新推荐文章于 2024-09-12 14:28:34 发布