其实想一下也不难,不要考虑农历
公历的话2月比较特殊了,处理一下就可以
1 /** 2 * 闰年366天,分别是: 3 * 31,29,31,30,31,30,31,31,30,31,30,31 4 * 平年分别是: 5 * 31,28,31,30,31,30,31,31,30,31,30,31 6 */ 7 import java.util.Scanner; 8 9 public class 一年中的第几天 {10 11 public static void main(String[] args) {12 // TODO Auto-generated method stub13 Scanner scanner=new Scanner(System.in);14 long year=scanner.nextInt();15 int month=scanner.nextInt();16 int day=scanner.nextInt();17 int[] month_length= {31,28,31,30,31,30,31,31,30,31,30,31};18 if(((year%4==0)&&(year%100!=0))||(year%400==0)){19 month_length[1]++;20 }21 int total_days=0;22 for(int i=0;i