题解 | 获得月份天数
获得月份天数
http://www.nowcoder.com/practice/13aeae34f8ed4697960f7cfc80f9f7f6
感觉这样简单一点:
public class Main{
public static void main(String[] args){
Scanner in = new Scanner (System.in);
int []a={31,28,31,30,31,30,31,31,30,31,30,31};
while(in.hasNextInt()){
int year = in.nextInt();
int month= in.nextInt();
if(year%4==0&&year/100!=0||year/400==0){
if(month==2){
System.out.println((a[1]+1));
} else System.out.println(a[month-1]);
}else
System.out.println(a[month-1]);
}
}
}

