输入某年某月某日,判断这一天是这一年的第几天?。
还是比较简单的,只是润年的计算规则要搞清楚
private static int daysOfDate(int year,int month ,int day) {
int[] monthDays = {31,28,31,30,31,30,31,31,30,31,30};
if(month == 1){
return day;
}
if(month == 2){
return 31+day;
}
if((year % 4 == 0 && year % 100 != 0 ) || year % 400 == 0){
monthDays[1] = 29;
}
int total = 0 ;
for (int i = 0; i < month -1; i++) {
total+= monthDays[i];
}
total+=day;
return total;
}