根据给定的年份和月份,获取该月份的天数。
输入格式:
输入在一行中给出2个正整数,一个代表年份,一个代表月份。月份不能大于12。
输出格式:
返回对应年月的天数。
输入样例
在这里给出一组输入。例如:
2016 2
输出样例:
在这里给出相应的输出。例如:
2016年2月有29天
import java.util.Scanner;
public class Main{
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int x=sc.nextInt();
int y=sc.nextInt();
int m;
if(((x%4==0)&&(x%100!=0))||x%400==0)
m=1;
else m=0;
switch(m)
{ case 0: switch(y)
{case 1:System.out.println(x+"年"+y+"月有31天");break;
case 2:System.out.println(x+"年"+y+"月有28天");break;
case 3:System.out.println(x+"年"+y+"月有31天");break;
case 4:System.out.println(x+"年"+y+"月有30天");break;
case 5:System.out.println(x+"年"+y+"月有31天");break;
case 6:System.out.println(x+"年"+y+"月有30天");break;
case 7:System.out.println(x+"年"+y+"月有31天");break;
case 8:System.out.println(x+"年"+y+"月有31天");break;
case 9:System.out.println(x+"年"+y+"月有30天");break;
case 10:System.out.println(x+"年"+y+"月有31天");break;
case 11:System.out.println(x+"年"+y+"月有30天");break;
case 12:System.out.println(x+"年"+y+"月有31天");break;
default:System.out.println("输入的月份不对");break;}break;
case 1: switch(y)
{case 1:System.out.println(x+"年"+y+"月有31天");break;
case 2:System.out.println(x+"年"+y+"月有29天");break;
case 3:System.out.println(x+"年"+y+"月有31天");break;
case 4:System.out.println(x+"年"+y+"月有30天");break;
case 5:System.out.println(x+"年"+y+"月有31天");break;
case 6:System.out.println(x+"年"+y+"月有30天");break;
case 7:System.out.println(x+"年"+y+"月有31天");break;
case 8:System.out.println(x+"年"+y+"月有31天");break;
case 9:System.out.println(x+"年"+y+"月有30天");break;
case 10:System.out.println(x+"年"+y+"月有31天");break;
case 11:System.out.println(x+"年"+y+"月有30天");break;
case 12:System.out.println(x+"年"+y+"月有31天");break;
default:System.out.println("输入的月份不对");break;}break;
}
}
}