public class Sun9 { public static void main(String[] args) { Scanner in =new Scanner(System.in); System.out.print("请输入年份:"); int year =in.nextInt(); System.out.print("请输入月份:"); int mouth = in.nextInt(); System.out.print("请输入几号:"); int day = in.nextInt(); int maxday=0; for(int i=1;i12) { year++; mouth-=12; } if(mouth<1) { year--; mouth=12-mouth; } switch(i){ case 1: case 3: case 5: case 7: case 8: case 10: case 12: maxday+=31; break; case 4: case 6: case 9: case 11: maxday+=30; break; case 2: maxday+=28; break; default: System.out.println("输入月份错误!"); } } if((mouth)>2&&((year%4==0)&&year%100!=0)||(year%400==0)){ maxday++; } maxday+=day; System.out.println("此天是第:"+maxday+"天"); } }
希望采纳